我有一個標籤欄控制器與5 UIViewController連接。它連接正確。但我想爲每個UIViewController製作NavigationRootViewController。如何使他們?如何使UITabBarController內的NavigationRootViewController
0
A
回答
-1
- (void)setupViewControllers
{
tabBarController = [[UITabBarController alloc] init];
HomeViewController *mainViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
UINavigationController *firstNavController = [[[UINavigationController alloc] initWithRootViewController:mainViewController] autorelease];
mainViewController.shouldReloadCount = YES;
[mainViewController release];
MapViewController *currentLocationController = [[MapViewController alloc] initWithNibName:@"MapView" bundle:nil];
UINavigationController *secondNavController = [[[UINavigationController alloc] initWithRootViewController:currentLocationController] autorelease];
[currentLocationController release];
FavoritesViewController *favouriteController = [[FavoritesViewController alloc] initWithNibName:@"FavoritesViewController" bundle:nil];
UINavigationController *thirdNavController = [[[UINavigationController alloc] initWithRootViewController:favouriteController] autorelease];
[favouriteController release];
AllNotificationsViewController *notifController = [[AllNotificationsViewController alloc] initWithNibName:@"AllNotificationsViewController" bundle:nil];
UINavigationController *fourthNavController = [[[UINavigationController alloc] initWithRootViewController:notifController] autorelease];
[notifController release];
SettingsViewController *settingsController = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil];
UINavigationController *fifthNavController = [[[UINavigationController alloc] initWithRootViewController:settingsController] autorelease];
[settingsController release];
tabBarController.viewControllers = [NSArray arrayWithObjects:firstNavController, secondNavController, thirdNavController,fourthNavController,fifthNavController, nil];
firstNavController.tabBarItem.image = [UIImage imageNamed:@"house.png"];
firstNavController.tabBarItem.title = @"Home";
secondNavController.tabBarItem.image = [UIImage imageNamed:@"map.png"];
secondNavController.tabBarItem.title = @"Locator";
thirdNavController.tabBarItem.image = [UIImage imageNamed:@"fav.png"];
thirdNavController.tabBarItem.title = @"Favorites";
fourthNavController.tabBarItem.image = [UIImage imageNamed:@"profile.png"];
fourthNavController.tabBarItem.title = @"Activities";
fifthNavController.tabBarItem.image = [UIImage imageNamed:@"settings.png"];
fifthNavController.tabBarItem.title = @"Settings";
//[self.view addSubview:tabBarController.view];
[[[UIApplication sharedApplication].windows objectAtIndex:0] addSubview:tabBarController.view];
}
0
嗨這解釋瞭如何使用接口生成器在UItabBarController中的選項卡內添加UINavigationController。
1)標籤欄控制器添加到主窗口
2)UINavigationControllers
3更換標籤欄裏面的物品的viewControllers)設置viewControllers作爲RootViewController的爲各個UINavigationControllers
相關問題
- 1. 如何SE內的UIImagePickerController的UITabBarController
- 2. 如何從的UITabBarController
- 3. 如何當的UITabBarController
- 4. 如何巢的UITabBarController
- 5. 用的UITableViewController內的UITabBarController
- 6. 來自UITabBarController內的popView UINavigationController
- 7. iphone的UITabBarController內存管理
- 8. 如何隱藏UITabBarController
- 9. 如何隱藏uitabbarcontroller
- 10. 如何設置上的UITabBarController
- 11. UITabBarController UIViewController與內部UITableView
- 12. iPhone - UITabbarController內可用區域
- 13. 如何在Swift上使用Storyboard上的UITabBarController內部的導航控制器
- 14. 如何讓UITabBarController擁有tabBarSelection
- 15. 如何從UITabBarController呈現MPMoviePlayerViewController?
- 16. 訪問UITabBarController的內容視圖
- 17. 如何presentModalViewController嵌套的UITabBarController和UINavigationController的
- 18. MonoTouch的:如何添加的UITabBarController
- 19. uitabbarcontroller
- 20. 如何刷新UITabBarController中的UIView?
- 21. 如何禁用UITabBarController中的選項卡?
- 22. UISplitViewController在UITabBarController方向問題內
- 23. 從XIB加載UITabBarController不包含任何來自XIB的內容
- 24. 如何使用UITabBarController的shouldSelectViewController委託方法
- 25. 如何使UITabBarController的「更多」按鈕返回到根視圖
- 26. 如何指定要由UITabBarController使用的視圖控制器類?
- 27. 的UITabBarController定製
- 28. UITabBarController中的TTPhotoViewController
- 29. UIImagePicker中的UITabBarController
- 30. IADS中的UITabBarController
你無法在autoreleased對象上調用'release',程序將崩潰。所以請檢查'[firstNavcontroller release];',[secondNavcontroller release]等等。 – Mat 2012-03-12 09:56:05
@Mat oops ..我錯過了。更新了我的答案。多謝,夥計。 – janusbalatbat 2012-03-12 10:08:27
謝謝你的幫助,我可以做到這一點。 – WaiToNZa 2012-03-12 10:31:38