navigationController pushViewController 多次跳转后返回
关于ios中 viewcontroller的跳转问题,其中有一种方式是采用navigationController pushViewController 的方法,比如我从主页面跳转到了一级页面,又从一级页面跳转到了二级页面,然后从二级页面跳转到了三级页面,依次类推。,如果一级一级的返回我知道是没有问题的,调用navigationController popViewControllerAnimated就行了。。但是某些情况下我可能想要马上回到主页面,而不是一级一级的返回(如果有很多层会很累的),那该怎么办呢?
返回根页面vc用 :
1
|
[self.navigationController popToRootViewController] |
返回指定的某个vc用下面(通过index定位)
1
|
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES]; |
或(通过class定位)
1
2
3
4
5
|
for (UIViewController *controller in self.navigationController.viewControllers) { if ([controller isKindOfClass:[你要跳转到的Controller class ]]) { [self.navigationController popToViewController:controller animated:YES]; } }
|
posted on 2015-07-07 09:40 cynthia116 阅读(194) 评论(1) 编辑 收藏 举报