我有一个ViewController1
可以将推送进入ViewController2
。反过来,这可以将推送到ViewController3
。我在UIBarButtonItem
中有一个ViewController1
可以推送到ViewController3
。但是,当我按下ViewController3
中的后退按钮时,我需要弹出ViewController2
。
我该怎么做?这是我试过的代码:
ViewController2 *VC2 = [[ViewController2 alloc] init];
ViewController3 *VC3 = [[ViewController3 alloc] init];
[self.navigationController pushViewController:VC2 animated:NO];
[self.navigationController pushViewController:VC3 animated:YES];
答案 0 :(得分:0)
试过你的解决方案,似乎对我有用, 但是,无论如何......如果由于任何原因它对你不起作用......试试这个:
NSArray *array = self.navigationController.viewControllers;
[self.navigationController setViewControllers:[array arrayByAddingObjectsFromArray:@[vc1,vc2]] animated:YES];
答案 1 :(得分:0)
根据@Camo的回答,这是我最终找到的内容。我通过ViewController3
提出ViewController1
。 Segue公司。然后,在ViewController3
viewDidLoad
中,我输入了以下代码:
NSArray *array = self.navigationController.viewControllers;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
id TVC = [storyboard instantiateViewControllerWithIdentifier:@"VC2"];
[self.navigationController setViewControllers:[array arrayByAddingObjectsFromArray:@[TVC, self]] animated:NO];