我有這樣的習俗navigationController動畫我想要實現,但我想要的代碼被執行,只有當一個特定的viewController是在棧上。這裏是代碼:如何在自定義navigationController代碼中定位特定的viewController?
class ARNImageTransitionNavigationController: UINavigationController, UINavigationControllerDelegate {
weak var interactiveAnimator : ARNTransitionAnimator?
var currentOperation : UINavigationControllerOperation = .None
override func viewDidLoad() {
super.viewDidLoad()
self.interactivePopGestureRecognizer?.enabled = false
self.delegate = self
}
func navigationController(navigationController: UINavigationController,
animationControllerForOperation operation: UINavigationControllerOperation,
fromViewController fromVC: UIViewController,
toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
self.currentOperation = operation
if let _interactiveAnimator = self.interactiveAnimator {
return _interactiveAnimator
}
if operation == .Push {
return ARNImageZoomTransition.createAnimator(.Push, fromVC: fromVC, toVC: toVC)
} else if operation == .Pop {
return ARNImageZoomTransition.createAnimator(.Pop, fromVC: fromVC, toVC: toVC)
}
return nil
}
func navigationController(navigationController: UINavigationController, interactionControllerForAnimationController animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
if let _interactiveAnimator = self.interactiveAnimator {
if self.currentOperation == .Pop {
return _interactiveAnimator
}
}
return nil
}
}
現在我該怎麼添加這段代碼確保它實現了它的所有方法,但只有當特定的viewController在堆棧上時纔會執行它。
這工作,謝謝 –
,但我還有一個查詢,你會介意非常簡短地打這[聊天](http://chat.stackoverflow.com/rooms/90086/navigation-transition)嗎? –