ios - ToView 在 Swift 中出现在 FromView 后面
问题描述
我通过向下一个视图控制器呈现自定义过渡动画来做一个相当简单的转场。
本质上,transition 会在屏幕外创建 toView,然后将其从右侧滑过 fromView,而 fromView 会以稍慢的速度从左侧滑出。解雇过渡则相反。
我的问题是在解除 toView 以返回 fromView 后,当我再次触发 segue 时,toView 在 fromView 下滑动而不是在上面滑动。这不会在第一次过渡时发生,但在之后的每个人身上都会发生。
我一生都无法弄清楚它为什么会这样做,更不用说如何解决它了。任何帮助都是极好的。
转义代码:
let storyboard = UIStoryboard(name: kOnboardingSignupStoryboard, bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: kOnboardingErrorIdentifier) as! OnboardingErrorViewController
vc.transitioningDelegate = self
vc.errorMessage = kErrorIncorrectPin
self.present(vc, animated: true, completion: nil)
关闭代码:
dismiss(animated: true, completion: nil)
过渡扩展:
extension OnboardingErrorViewController: UIViewControllerTransitioningDelegate {
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return FromRightDeck()
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return DismissFromRightDeck()
}
解决方案
好的,所以我在深入研究动画代码后设法解决了它。最初我不认为这与它有任何关系,因为它在第一次和每隔一次我使用动画时都可以正常工作。但是,有一行错误的代码推送到我在测试中使用的 toView z 位置,这导致了这个问题。
推荐阅读
- opengl - 如何在 glfw3 中使用 glut 原语?
- java - 如何使用 MaterialShapeDrawable 模仿 MaterialCardView 的视觉效果
- javascript - 如何在 dhtmlx 甘特图中设置日期、年份等行的自动高度
- python - 我如何查看某人的余额?
- python-3.x - 使 if 语句不关心大小写
- reactjs - 从 graphql 获取数据以做出反应
- c++ - C++ 模板和函数重载
- c# - 状态 Epilog 中的令牌 StartElement 将导致无效的 XML 文档
- selenium - 要求硒 *find_element_by_class_name
- html - 文本超出网格大小