1

我有多个视图,其中一些是 tabBarControllers 的一部分,并且视图正在推送到一个名为View2. 当我返回显示 view2 的视图时,我将如何返回选项卡栏中的特定选项卡而不是返回第一个选项卡?

我对返回第一个视图的按钮的操作是

-(IBAction)goBackButton:(id)sender
{
    ViewController *firstView = [myStoryboard instantiateViewControllerWithIdentifier:@"view1"];
    [self presentViewController:firstView animated:YES completion:nil];
}

所以 ViewController 是标签栏中第一个视图的类,而 tabBarController 的标识符为“view1”

4

1 回答 1

5

如果View2按下,则您的后退按钮操作应调用:

[self.navigationController popViewControllerAnimated:YES];

如果View2模态,那么您的后退按钮操作应调用:

[self dismissViewControllerAnimated:YES completion:nil];

并且无论哪个场景调用View2都会为您重新出现。

于 2013-09-28T13:32:40.233 回答