1

我有一个带有通过模型视图控制器调用的菜单的 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];

似乎没有做的伎俩..

4

1 回答 1

1

试试这个:

YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];

appDelegate.tabBarController.selectedIndex = 3;
于 2012-09-06T03:52:17.743 回答