我有一个tabBar应用程序,其菜单通过模型视图控制器调用。然后选择一个选项。我希望在更改tabBAr的SelectedIndex时忽略它。
这是我的代码片段:
FirstTabBarController:
这就是所谓的“菜单”
-(IBAction)pressedButton {
GWDNativeViewController *secondView = [[GWDNativeViewController alloc] initWithNibName:nil bundle:nil];
[secondView setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentModalViewController:secondView animated:YES];
}
这是在GWDNativeViewController(菜单)视图中解雇的代码:
-(IBAction)dismissThisView {
//Insert code to dismiss here
[self dismissModalViewControllerAnimated:YES];
[(UITabBarController *)self.parentViewController setSelectedIndex:3];
}
该行:
[(UITabBarController *)self.parentViewController setSelectedIndex:3];
似乎没有做到这一点..
答案 0 :(得分:1)
试试这个:
YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.tabBarController.selectedIndex = 3;