推出视图控制器后推视图控制器
我有这个导航堆栈
RootVC —> VC1 – >(出示) – > ModalVC
我有VC2 (不在导航堆栈中)。
在展示ModalVC时 ,我想点击我的ModalVC中的buttonclosuresModalVC,然后在VC1之后将VC2推入导航堆栈。 它应该是这样的:
RootVC —> VC1 —> VC2
我尝试了很多方法来制作它,但是只有当我返回到我的RootVC时才推动事件触发。
我试图与代表:
在ModalVC上点击:
[self dismissViewControllerAnimated:YES completion:^{ if ([self.delegate respondsToSelector:@selector(dismissAndPush:)]) { [self.delegate performSelector:@selector(dismissAndPush:) withObject:VC2]; } }];
在VC1 :
- (void)dismissAndPush:(UIViewController *)vc { [self.navigationController pushViewController:vc animated:NO]; }
请帮助理解这种行为。 我的错误在哪里?
其他错误。 如果我正确理解:解雇呈现的视图控制器之前的一些animation阻止导航堆栈中的animation。 我用两种方法解决了这个问题:
1)在解散之前删除或设置正确的animation
2)在导航控制器中使用setViewControllers(我select它)
- (void)dismissAndPush:(UIViewController *)vc { [self dismissViewControllerAnimated:NO completion:^{ NSMutableArray *mutableControllers = [NSMutableArray arrayWithArray:self.navigationController.viewControllers]; NSArray *controllers = [mutableControllers arrayByAddingObject:vc]; [self.navigationController setViewControllers:controllers animated:NO]; }]; }
来自Apple文档 :
呈现视图控制器负责解除其呈现的视图控制器。
所以,VC1应该解散ModalVC,试着做到这一点
点击ModalVC:
if ([self.delegate respondsToSelector:@selector(dismissAndPush:)]) { [self.delegate performSelector:@selector(dismissAndPush:) withObject:VC2]; }
在VC1:
- (void)dismissAndPush:(UIViewController *)vc { [self dismissViewControllerAnimated:YES completion:^{ [self.navigationController pushViewController:vc animated:NO]; }]; }
- 消失在UINavigationController中的TableViewController中的UISearchController
- 图像资源从反应原生应用程序中消失
- iOS 7 SDK – 用户界面导航栏有时会变暗,有时甚至没有。 但为什么?
- 以编程方式构build/导航导航控制器
- 如何添加项目在uinavigationbar在一个特定的位置?
- iOS 7:如何设置UIBarButtonItem backButtonImage为UIControlStateHighlighted?
- 如何在导航栏中改变titleView的大小。 因为navigationBar中titleView和backButton之间存在差距
- 如何使用Mapbox实现转弯导航
- iOS Swift通过推送通知以编程方式导航到某个ViewController