我有一個標籤欄控制器與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內的UINavigationController?
- 3. 如何訪問UITabBarController內的NavigationController
- 4. 如何巢的UITabBarController
- 5. 如何從的UITabBarController
- 6. 如何當的UITabBarController
- 7. MonoTouch中使用的UITabBarController內DialogViewController
- 8. 用的UITableViewController內的UITabBarController
- 9. iphone的UITabBarController內存管理
- 10. 來自UITabBarController內的popView UINavigationController
- 11. 如何隱藏UITabBarController
- 12. 如何隱藏uitabbarcontroller
- 13. 如何加載UITabBarController?
- 14. UITabBarController如何工作?
- 15. 如何設置上的UITabBarController
- 16. 如何從app delegate訪問uitabbarcontroller中的uinavigationcontroller內的uitableview?
- 17. iPhone - UITabbarController內可用區域
- 18. UITabBarController UIViewController與內部UITableView
- 19. 如何在Swift上使用Storyboard上的UITabBarController內部的導航控制器
- 20. 使用UITabBarController
- 21. 如何在iOS7中調整UITabBarController內容視圖的大小?
- 22. 如何一個的UITabBarController內設置分割視圖控件
- 23. 如何從UITabBarController呈現MPMoviePlayerViewController?
- 24. 如何讓UITabBarController擁有tabBarSelection
- 25. 訪問UITabBarController的內容視圖
- 26. MonoTouch的:如何添加的UITabBarController
- 27. 如何presentModalViewController嵌套的UITabBarController和UINavigationController的
- 28. 使用UITabbarController與pushViewController
- 29. 使用兩個UITabBarController
- 30. 的UITabBarController不使用NavigationController
你無法在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