ในผู้รับมอบสิทธิ์แอปของฉัน ฉันโหลดตัวควบคุมมุมมองที่ด้านบนของแถบแท็บ คอนโทรลเลอร์นี้มีปุ่มอยู่สามปุ่ม หนึ่งปุ่มสำหรับนำทางไปยังแต่ละแท็บ เมื่อกดปุ่มที่สอง ฉันต้องการยกเลิกตัวควบคุมมุมมองและไปที่แท็บที่สอง แต่ดูเหมือนว่าจะไม่ทำงานตามปกติ
ตัวแทนแอปของฉัน:
- (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;
และ
[self.tabBarController setSelectedIndex:1];
ใครสามารถช่วยฉันและอธิบายสิ่งที่ฉันขาดหายไป?