-1

我有一个ViewController1可以将 segue 推入ViewController2. 反过来,这可以将一个 push segue 转换为ViewController3. 我有一个UIBarButtonIteminViewController1可以将 segue 推入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];
4

2 回答 2

0

尝试了您的解决方案,并且似乎对我有用,但是,无论如何..如果出于任何原因它对您不起作用...试试这个:

NSArray *array = self.navigationController.viewControllers;
[self.navigationController setViewControllers:[array arrayByAddingObjectsFromArray:@[vc1,vc2]] animated:YES];
于 2013-09-10T23:17:28.720 回答
0

这是我最终根据@Camo 的回答找到的。我ViewController3ViewController1通过。继续。然后,在 中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];
于 2013-09-11T16:30:57.147 回答