【发布时间】:2015-01-12 00:46:07
【问题描述】:
我正在尝试在 UIViewController 的堆栈上以交互方式关闭 UINavigationController
我。我介绍如下:
UIViewController *vc = [UIViewController new];
UINavigationController *nav = [[UINavigationController alloc] initWithRoot:vc];
[self presentViewController:nav animated:YES completion:nil];
ii.. 在我的 ViewController 中,我在 .h 文件中进行了设置。在.m 文件中我设置了self.transitioningDelegate.self 我也尝试了self.navigationController.transitioningDelegate = self
三。最后我实现了委托方法:
#pragma mark - ViewControllerTransitioning Delegate Methods
- (id<UIViewControllerAnimatedTransitioning>)
animationControllerForPresentedController:(UIViewController *)presented
presentingController:(UIViewController *)presenting
sourceController:(UIViewController *)source {
NSLog(@"\n\nTRANSIT 1\n\n");
// allow the interaction controller to wire-up its gesture recognisers
[_interactionController wireToViewController:presented
forOperation:CEInteractionOperationDismiss];
_animationController.reverse = NO;
return _animationController;
}
- (id<UIViewControllerAnimatedTransitioning>)
animationControllerForDismissedController:(UIViewController *)dismissed {
NSLog(@"\n\nTRANSIT 2\n\n");
_animationController.reverse = YES;
return _animationController;
}
- (id<UIViewControllerInteractiveTransitioning>)
interactionControllerForDismissal:
(id<UIViewControllerAnimatedTransitioning>)animator {
NSLog(@"\n\nTRANSIT 3\n\n");
// provide the interaction controller, if an interactive transition is in progress
return _interactionController.interactionInProgress
? _interactionController : nil;
}
四。不幸的是,交互部分永远不会执行。当我手动点击调用[self dismissViewControllerAnimated:YES completion:nil];的按钮时
Transit 2 和 Transit 3 都已打印,但从未到达 Transit 1。有人对这可能是什么有任何建议吗?谢谢!
【问题讨论】:
-
我不确定,但你可以试试
[self.navigationController popViewControllerAnimated:YES];而不是[self dismissViewControllerAnimated:YES completion:nil];。我猜是这样。 -
这很遗憾行不通
标签: ios uiviewcontroller uinavigationcontroller transitions