【发布时间】:2014-08-06 00:19:07
【问题描述】:
我为模态转场使用自定义转换,使用 UIViewControllerAnimatedTransitioning 委托实现。所有 segues 都通过 Storyboard 设置。
我有两个导航控制器,都具有单根 VC 设置。我们称它们为1st NVC、1st VC、2nd NVC 和2nd VC。
1st VC采用UIViewControllerAnimatedTransitioning协议,实现简单返回animator:
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
return [ModalTransitionAnimator new];
}
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
return [ModalTransitionAnimator new];
}
当1st VC -> 2nd NVC 发生任何转场时,1st VC 会在 prepareForSegue: 中捕获事件并分配 transitioningDelegate 以及 modalPresentationStyle,因为您无法从 IB 执行此操作:
UINavigationController* destination = (UINavigationController*)segue.destinationViewController;
destination.transitioningDelegate = self;
destination.modalPresentationStyle = UIModalPresentationCustom;
所以一切看起来都很好,我运行了一个非常酷的动画,目标控制器出现了,所有viewWillAppear: 和viewDidAppear: 都按正确的顺序触发。
所以现在在屏幕上,我有2nd NVC,里面有2nd VC。
我点击导航栏中的“取消”按钮,在1st VC 上触发展开动作,但没有发生向后动画。我的意思是事实上2nd VC 仍在屏幕上。
显然没有人调用dismissViewControllerAnimated。我想 Storyboard 很困惑,找不到回去的路,因为 2nd NVC 最初是模态呈现的,然后其他一些控制器请求展开。你平时是怎么处理的?
【问题讨论】:
标签: objective-c uikit uiviewanimationtransition