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