我以编程方式创建了一个带有视图等的 TabBarController。现在我想在按钮按下时显示这个 TabBarController。我怎么做?目前我以模态方式展示它,但它不起作用 - 引发 sigtrap 错误。
这是我的 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 的 Button Press 事件访问此 tabBarController 的代码 -
- (IBAction)quickBrowse:(UIButton *)sender
{
TabBarViewController * tabBarController = [[TabBarViewController alloc]init];
[self presentModalViewController:tabBarController animated:YES];
[tabBarController release];
}