我有六个viewControllers
。在viewController1
我有一个button
需要我到viewController6
。我怎样才能回到导航控制器
现在从viewController6
我想分别弹出回viewController5
,viewController4
,viewController3
,viewController2
和viewController1
。
我该怎么做?
我有六个viewControllers
。在viewController1
我有一个button
需要我到viewController6
。我怎样才能回到导航控制器
现在从viewController6
我想分别弹出回viewController5
,viewController4
,viewController3
,viewController2
和viewController1
。
我该怎么做?
试试这个,
NSMutableArray *allViewControllers = [NSMutableArray arrayWithArray: self.navigationController.viewControllers];
插入您需要的视图控制器,以便使用
[allViewControllers insertObject:viewControllerX atIndex:requiredIndex];
如果你想只更换以前的viewController使用,
[allViewControllers replaceObjectAtIndex:indexRequired withObject:viewControlerX];
然后重新设置导航堆栈,
self.navigationController.viewControllers = allViewControllers;
那么你可以使用以下弹出回任何的viewController:
[self.navigationController popViewControllerAnimated:YES];
,如果你想弹出仅1 ViewController
,或使用[self.navigationController popToRootViewControllerAnimated:YES];
回到拳头ViewController
是的,这是可能的,你可以使用[self.navigationController popViewControllerAnimated:YES];
。
,如果你想从控制器栈中弹出1 ViewController
[self.navigationController popViewControllerAnimated:YES];
回到fist ViewController
。
[self.navigationController popToRootViewControllerAnimated:YES];
更多信息使用这个链接
嗨迪克西特,感谢您的答复。但我认为你没有得到我的问题。首先,我想从VC1使用按钮单击VC6,然后从VC6我想要移回到VC5,VC4,VC3,VC2和VC1。 – Ankita
使用
popToViewController:animated或
setViewControllers:animated
用[self.navigationController pushViewController:]按照该顺序 : 从ViewController1,6,5,4,3,2
,并用[self.navigationController popToRootViewControllerAnimated:]从ViewController2去1.
您有2种使用导航控制器进行导航的方法。如果在[self.navigationController popToViewController: animated:BOOL]' 之前已经显示(推送)了控制器,或者您可以在控制器显示第一个时间的情况下“推送”控制器,则可以“弹出”[ ] self.navigationController pushViewController: animated:BOOL]' –
Spire