1
在我的应用程序委托中,我在我的选项卡上加载了一个视图控制器。该控制器上有三个按钮,一个用于导航到每个选项卡。当按下第二个按钮时,我想关闭视图控制器并转到第二个选项卡。但这似乎并不正常。从ModalViewController中选择第二个选项卡
我的AppDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//-- Insert a delay of 5 seconds before the splash screen disappears
[NSThread sleepForTimeInterval:3.0];
// Set the tab bar controller as the window's root view controller and display.
self.window.rootViewController = self.tabBarController;
// Set StartView to load first
StartViewController *startViewController = [[StartViewController alloc] initWithNibName:@"StartView" bundle: nil];
[window addSubview: [startViewController view]];
[window makeKeyAndVisible];
[self.tabBarController presentModalViewController:startViewController animated:NO];
[startViewController release];
return YES;
}
,这里是我目前的IBAction为,这似乎不工作:
- (IBAction) toSecondView:(id)sender
{
// Show status bar
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
[(UITabBarController *)self.parentViewController setSelectedIndex:1];
[self dismissModalViewControllerAnimated:NO];
}
我想这些也没有成功:
self.tabBarController.selectedIndex = 1;
and
[self.tabBarController setSelectedIndex:1];
任何人都可以帮我解释我失踪的事吗?
它happend因为,你已经添加视图 - 控制到窗口子视图,然后呈现的是对的viewController tabBarController – Kamarshad 2012-02-27 11:03:56