[英]Custom unwind segue crashing in iOS11
更新資料
我發現,如果我從提供的控制器中執行此操作,則一切正常
self.dismiss(animated: true)
然后執行自定義腳本的動畫。 但是,如果我嘗試使用像這樣的放松策略:
self.performSegue(withIdentifier: "logoDisplayed", sender: self)
然后我得到下面提到的崩潰。 另外,我還發現,只有將“種類”設置為“模態呈現”時,自定義序列才有效。 如果我將其設置為“自定義”,則再次崩潰會告訴我,即使明顯存在也沒有perform()
。
仍在嘗試找出答案。
原始帖子
但是我無法在iOS11中獲得自定義的解散功能。 以下是我正在使用的自定義序列。 當我將其設置為模型segue的類時,它可以完美工作,但是當我將其設置為unsegue segue的類時,則不能工作。 相反,應用程序因以下錯誤而崩潰:
2017-11-20 22:29:09.640934+1100 Crux[46709:6046351] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Could not perform segue with identifier 'logoDisplayed'.
A segue must either have a performHandler or it must override -perform.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001100c012b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010f06bf41 objc_exception_throw + 48
2 UIKit 0x0000000111c1061d -[UIStoryboardSegue _prepare] + 0
3 Crux 0x000000010dacecc8 _T04Crux13AnimatedSegueC7performyyF + 280
...
segue的設置如下:
我的segue代碼是這樣的:
class FadeInAnimator: NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 2.0
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let containerView = transitionContext.containerView
let toVC = transitionContext.viewController(forKey:UITransitionContextViewControllerKey.to)
containerView.addSubview(toVC!.view)
toVC!.view.alpha = 0.0
let duration = transitionDuration(using:transitionContext)
UIView.animate(withDuration:duration,
animations: {
toVC!.view.alpha = 1.0
},
completion: { finished in
let cancelled = transitionContext.transitionWasCancelled
transitionContext.completeTransition(!cancelled)
})
}
}
class AnimatedSegue:UIStoryboardSegue, UIViewControllerTransitioningDelegate {
override func perform() {
source.transitioningDelegate = self
destination.transitioningDelegate = self
super.perform()
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return FadeInAnimator()
}
func animationController(forPresented presented: UIViewController,
presenting: UIViewController,
source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return FadeInAnimator()
}
}
有人知道我可能在哪里出問題了嗎?
找到了問題。 我在源控制器中有一些舊代碼:
override func segueForUnwinding(to toViewController: UIViewController, from fromViewController: UIViewController, identifier: String?) -> UIStoryboardSegue? {
return AnimatedSegue(identifier: identifier, source: fromViewController, destination: toViewController)
}
被調用並導致問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.