我有多个视图,其中一些是tabBarControllers的一部分,并且这些视图正在推送到一个名为的视图控制器View2
。当我回到显示view2的视图时,如何回到选项卡栏中的特定选项卡而不是第一个选项卡?
我对返回到第一个视图的按钮的操作是
-(IBAction)goBackButton:(id)sender
{
ViewController *firstView = [myStoryboard instantiateViewControllerWithIdentifier:@"view1"];
[self presentViewController:firstView animated:YES completion:nil];
}
因此,ViewController是选项卡栏中第一个视图的类,并且tabBarController的标识符为“ view1”
如果View2
已按下,则您的后退按钮操作应调用:
[self.navigationController popViewControllerAnimated:YES];
如果View2
是模态,则您的后退按钮操作应调用:
[self dismissViewControllerAnimated:YES completion:nil];
无论调用哪个场景,View2
都会重新出现。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句