我通过向下一个视图控制器呈现自定义过渡动画来进行相当简单的搜索。

本质上,过渡会在屏幕上创建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()
}


Gif of the issue

最佳答案

好的,因此在深入研究动画代码后设法解决了这个问题。最初,我认为这与它没有任何关系,因为它在我第一次使用动画以及每次使用动画时都可以正常工作。但是,我在测试中使用了一行错误的代码将其推到toView z位置,这导致了此问题。

08-19 12:17