- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在努力解决以下问题。我在文档中找不到我做错的任何事情。我已经通过调试器进行了爬网,并将各种信息都转储到了控制台,但是无法解决所看到的问题。
我的顶级视图控制器是UINavigationController的子类。它包含UIPageViewController的子类,该子类将用于可视化我的数据。它还包含用于设置应用程序设置的UITableViewController的子类。该“选项”视图通过推送功能“链接”到页面视图控制器。至此,一切正常。
当我想区分可视化数据的各种方式(页面视图控制器中的水平滚动)与引入选项视图之间的视觉过渡时,问题就开始了。因此,我创建了一个自定义动画,以将选项控制器从屏幕顶部“拉入”(按入),或者将选项控制器“滚动”到屏幕顶部(弹出)。我使用navigationController:animationControllerFor:operation:from:to:方法在导航控制器上设置此动画。
在显示选项控制器之前,在设备旋转期间一切似乎都工作正常。显示/关闭选项控制器后,数据可视化控制器的布局在旋转过程中会分解。当关闭选项控制器时,它以设备所处的方向正确显示,但以相反的方向错误地播放。
似乎导航控制器(或可能的页面视图控制器)已经忘记了如何处理状态,导航和工具栏的高度。
以下显示的调试屏幕截图说明了5s模拟器上的问题
初始状态。请注意,内容视图(红色)在状态,导航和工具栏下方。
将方向旋转到水平。到目前为止,一切正常。调试控制台显示将视图“旋转”为(568x212)的大小,状态,导航和工具栏的前后高度,屏幕大小,框架矩形和图层位置。我没有在此处显示它,但是图层锚点从(0.5,0.5)不变。
请注意,目标旋转大小是使用以下规则设置的:
rot_width(568)= old_frame_height(460)+ sum_of_bar_heights(108)
rot_height(212)= old_frame_width(320)-sum_of_bar_heights(108)
并使用以下规则设置结果帧大小:
new_frame_width(568)= rot_width(568)
new_frame_height(256)= rot_height(212)+ change_in_bar_height(108-64)
所得到的帧原点(0,64)从屏幕顶部偏移状态栏(20)和导航栏(44)的总和。
将方向旋转回垂直方向。再次,一切都很好。调试控制台为“反向”旋转添加与上述相同的信息。旋转大小和生成的帧大小遵循与上述相同的规则。
使用自定义动画将选项编辑器控制器视图推入导航堆栈。调试控制台为上面的(当前不可见)内容视图添加与上面相同的信息。请注意,没有任何改变。
使用自定义动画将选项编辑器控制器视图弹出导航堆栈。上方的内容视图返回视图。调试控制台添加与上述相同的信息。同样,没有任何变化。
注意,堆叠顺序与显示选项编辑器之前的顺序不同。
使用默认的过渡动画器时,此堆栈重排序不成立(通过从pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted返回nil)
重复第1步。这就是要“变态”的地方。内容视图不再紧贴导航栏和工具栏。调试控制台显示,轮换的所有内容与步骤1中的相同。
但是,轮换的结果与步骤1不同。规则似乎已更改。不再调整生成的框架大小以适应状态,导航和工具栏高度的更改,并且框架原点与旋转之前的原始位置相同。
重复执行步骤2。看来,所有内容都是固定的,但这仅仅是因为它正在按照新的调整大小规则播放。
在此处显示了我的动画师类(完整显示,除了用于产生上面显示的调试信息的探针外):
class OptionsViewAnimator: NSObject, UIViewControllerAnimatedTransitioning
{
var type : UINavigationControllerOperation
init(_ type : UINavigationControllerOperation)
{
self.type = type
}
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return 0.35
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
{
if self.type == .push { showOptions(using:transitionContext) }
else if self.type == .pop { hideOptions(using:transitionContext) }
}
func showOptions(using context: UIViewControllerContextTransitioning)
{
let src = context.viewController(forKey: .from)!
let srcView = context.view(forKey: .from)!
let dstView = context.view(forKey: .to)!
var dstEnd = context.finalFrame(for: context.viewController(forKey: .to)!)
let barHeight = (src.navigationController?.toolbar.frame.height) ?? 0.0
dstEnd.size.height += barHeight
dstView.frame = dstEnd
dstView.layer.position = dstEnd.origin
dstView.layer.anchorPoint = CGPoint(x:0.0,y:0.0)
dstView.transform = dstView.transform.scaledBy(x: 1.0, y: 0.01)
UIApplication.shared.keyWindow!.insertSubview(dstView, aboveSubview: srcView)
UIView.animate(withDuration: 0.35, animations:
{
dstView.transform = .identity
}
) {
(finished)->Void in
context.completeTransition( !context.transitionWasCancelled )
}
}
func hideOptions(using context: UIViewControllerContextTransitioning)
{
let dst = context.viewController(forKey: .to)!
let srcView = context.view(forKey: .from)!
let dstView = context.view(forKey: .to)!
let dstEnd = context.finalFrame(for: context.viewController(forKey: .to)!)
dstView.frame = dstEnd
srcView.layer.position = dstEnd.origin
srcView.layer.anchorPoint = CGPoint(x:0.0,y:0.0)
srcView.transform = .identity
UIApplication.shared.keyWindow!.insertSubview(dstView, belowSubview: srcView)
UIView.animate(withDuration: 0.35, animations:
{
srcView.transform = srcView.transform.scaledBy(x: 1.0, y: 0.01)
}
) {
(finished)->Void in
context.completeTransition( !context.transitionWasCancelled )
}
}
}
最佳答案
由于您希望它覆盖UINavigation控制器栏,因此有任何理由不使用自定义模式(在情节提要中以模态形式呈现)。无论哪种方式,我都构建了它以使其与添加窗口无关。在您测试之后,请让我知道,但在我的测试中,两者都可以正常使用。
import UIKit
class OptionsViewAnimator: NSObject, UIViewControllerAnimatedTransitioning,UIViewControllerTransitioningDelegate
{
var isPresenting = true
fileprivate var isNavPushPop = false
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
{
return 0.35
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
{
if isPresenting { showOptions(using:transitionContext) }
else { hideOptions(using:transitionContext) }
}
func showOptions(using context: UIViewControllerContextTransitioning)
{
let src = context.viewController(forKey: .from)!
let dstView = context.view(forKey: .to)!
let frame = context.finalFrame(for: context.viewController(forKey: .to)!)
let container = context.containerView
dstView.frame = frame
dstView.layer.position = CGPoint(x: container.frame.origin.x, y: container.frame.origin.y + frame.origin.y)
print("container = \(container.frame)")
dstView.layer.anchorPoint = CGPoint(x:container.frame.origin.x,y:container.frame.origin.y)
dstView.transform = dstView.transform.scaledBy(x: 1.0, y: 0.01)
container.addSubview(dstView)
UIView.animate(withDuration: 0.35, animations: { dstView.transform = .identity } )
{
(finished)->Void in
src.view.transform = .identity
context.completeTransition( !context.transitionWasCancelled )
}
}
func hideOptions(using context: UIViewControllerContextTransitioning)
{
let srcView = context.view(forKey: .from)!
let dstView = context.view(forKey: .to)!
let container = context.containerView
container.insertSubview(dstView, belowSubview: srcView)
srcView.layer.anchorPoint = CGPoint(x:container.frame.origin.x,y:container.frame.origin.y)
dstView.frame = context.finalFrame(for: context.viewController(forKey: .to)!)
dstView.layoutIfNeeded()
UIView.animate(withDuration: 0.35, animations:
{ srcView.transform = srcView.transform.scaledBy(x: 1.0, y: 0.01) } )
{
(finished)->Void in
context.completeTransition( !context.transitionWasCancelled )
}
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
isPresenting = false
return self
}
func animationController(forPresented presented: UIViewController,
presenting: UIViewController,
source: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
isPresenting = true
return self
}
}
extension OptionsViewAnimator: UINavigationControllerDelegate
{
func navigationController(_ navigationController: UINavigationController,
animationControllerFor operation: UINavigationControllerOperation,
from fromVC: UIViewController,
to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
isNavPushPop = true
self.isPresenting = operation == .push
return self
}
}
let animator = OptionsViewAnimator()
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let dvc = segue.destination
dvc.transitioningDelegate = animator
}
self.navigationController?.delegate = animator
func navigationController(_ navigationController: UINavigationController,
animationControllerFor operation: UINavigationControllerOperation,
from fromVC: UIViewController,
to toVC: UIViewController
) -> UIViewControllerAnimatedTransitioning?
{
var animator : OptionsViewAnimator?
if ( toVC is OptionsViewController && operation == .push ){
animator = OptionsViewAnimator()
animator?.isPresenting = true
}else if ( fromVC is OptionsViewController && operation == .pop ){
animator = OptionsViewAnimator()
animator?.isPresenting = false
}
return animator
}
关于ios - UINavigationController忘记了自定义过渡动画后如何旋转子 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42479321/
好的,所以我编辑了以下... 只需将以下内容放入我的 custom.css #rt-utility .rt-block {CODE HERE} 但是当我尝试改变... 与 #rt-sideslid
在表格 View 中,我有一个自定义单元格(在界面生成器中高度为 500)。在该单元格中,我有一个 Collection View ,我按 (10,10,10,10) 固定到边缘。但是在 tablev
对于我的无能,我很抱歉,但总的来说,我对 Cocoa、Swift 和面向对象编程还很陌生。我的主要来源是《Cocoa Programming for OS X》(第 5 版),以及 Apple 的充满
我正在使用 meta-tegra 为我的 NVIDIA Jetson Nano 构建自定义图像。我需要 PyTorch,但没有它的配方。我在设备上构建了 PyTorch,并将其打包到设备上的轮子中。现
在 jquery 中使用 $.POST 和 $.GET 时,有没有办法将自定义变量添加到 URL 并发送它们?我尝试了以下方法: $.ajax({type:"POST", url:"file.php?
Traefik 已经默认实现了很多中间件,可以满足大部分我们日常的需求,但是在实际工作中,用户仍然还是有自定义中间件的需求,为解决这个问题,官方推出了一个 Traefik Pilot[1] 的功
我想让我的 CustomTextInputLayout 将 Widget.MaterialComponents.TextInputLayout.OutlinedBox 作为默认样式,无需在 XML 中
我在 ~/.emacs 中有以下自定义函数: (defun xi-rgrep (term) (grep-compute-defaults) (interactive "sSearch Te
我有下表: 考虑到每个月的权重,我的目标是在 5 个月内分散 10,000 个单位。与 10,000 相邻的行是我最好的尝试(我在这上面花了几个小时)。黄色是我所追求的。 我试图用来计算的逻辑如下:计
我的表单中有一个字段,它是文件类型。当用户点击保存图标时,我想自然地将文件上传到服务器并将文件名保存在数据库中。我尝试通过回显文件名来测试它,但它似乎不起作用。另外,如何将文件名添加到数据库中?是在模
我有一个 python 脚本来发送电子邮件,它工作得很好,但问题是当我检查我的电子邮件收件箱时。 我希望该用户名是自定义用户名,而不是整个电子邮件地址。 最佳答案 发件人地址应该使用的格式是: You
我想减小 ggcorrplot 中标记的大小,并减少文本和绘图之间的空间。 library(ggcorrplot) data(mtcars) corr <- round(cor(mtcars), 1)
GTK+ noob 问题在这里: 是否可以自定义 GtkFileChooserButton 或 GtkFileChooserDialog 以删除“位置”部分(左侧)和顶部的“位置”输入框? 我实际上要
我正在尝试在主页上使用 ajax 在 magento 中使用 ajax 显示流行的产品列表,我可以为 5 或“N”个产品执行此操作,但我想要的是将分页工具栏与结果集一起添加. 这是我添加的以显示流行产
我正在尝试使用 PasswordResetForm 内置函数。 由于我想要自定义表单字段,因此我编写了自己的表单: class FpasswordForm(PasswordResetForm):
据我了解,新的 Angular 7 提供了拖放功能。我搜索了有关 DnD 的 Tree 组件,但没有找到与树相关的内容。 我在 Stackblitz 上找到的一个工作示例.对比drag'ndrop功能
我必须开发一个自定义选项卡控件并决定使用 WPF/XAML 创建它,因为我无论如何都打算学习它。完成后应该是这样的: 到目前为止,我取得了很好的进展,但还有两个问题: 只有第一个/最后一个标签项应该有
我要定制xtable用于导出到 LaTeX。我知道有些问题是关于 xtable在这里,但我找不到我要找的具体东西。 以下是我的表的外观示例: my.table <- data.frame(Specif
用ejs在这里显示日期 它给我结果 Tue Feb 02 2016 16:02:24 GMT+0530 (IST) 但是我需要表现为 19th January, 2016 如何在ejs中执行此操作?
我想问在 JavaFX 中使用自定义对象制作 ListView 的最佳方法,我想要一个每个项目如下所示的列表: 我搜了一下,发现大部分人都是用细胞工厂的方法来做的。有没有其他办法?例如使用客户 fxm
我是一名优秀的程序员,十分优秀!