0
我已經編程創建了一個帶有視圖的TabBarController等。現在我想在Button按鈕上顯示這個TabBarController。我怎麼做?目前我正在以模態方式呈現它,但它不起作用 - 拋出sigtrap錯誤。在按鈕上訪問TabBarController按
這是我的TabBarController
@implementation TabBarViewController
- (void) loadView
{
HomeViewController * homeViewController = [[HomeViewController alloc]initWithNibName:@"HomeViewController" bundle:nil];
UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.view.frame = CGRectMake(0, 0, 320, 460);
// Set each tab to show an appropriate view controller
[tabBarController setViewControllers:[NSArray arrayWithObjects:homeViewController, homeViewController, nil]];
[self.view addSubview:tabBarController.view];
[homeViewController release];
[tabBarController release];
}
代碼這是我從我的mainViewController從按鈕按下事件訪問該tabBarController碼 -
- (IBAction)quickBrowse:(UIButton *)sender
{
TabBarViewController * tabBarController = [[TabBarViewController alloc]init];
[self presentModalViewController:tabBarController animated:YES];
[tabBarController release];
}