2014-03-05 93 views

回答

2
UIViewController *vc1 = [[UIViewController alloc] init]; 
vc1.title = @"FIRST"; 
vc1.view.backgroundColor = [UIColor blueColor]; 

UIViewController *vc2 = [[UIViewController alloc] init]; 
vc2.title = @"SECOND"; 
vc2.view.backgroundColor = [UIColor redColor]; 

UITabBarController *tabBar = [[UITabBarController alloc] init]; 
tabBar.viewControllers = @[vc1,vc2]; 
tabBar.selectedIndex = 1; 
tabBar.view.frame = CGRectMake(50, 50, 220, 320); 

[tabBar willMoveToParentViewController:self]; 
[self.view addSubview:tabBar.view]; 
[self addChildViewController:tabBar]; 
[tabBar didMoveToParentViewController:self]; 
+0

我应该把在我MainViewController? –

+0

把它放在你想添加tabBar – morroko

+0

谢谢,但我可以在哪里放置物品的动作? –

相关问题