我有一個基於視圖的應用程序,其中在第一個視圖中我不希望tabbar控制器和視圖以外的視圖(即從第二個視圖..)我想有tabbar控制器。 我GOOGLE了它,但無法得到一個解決方案。如何將uitabbarcontroller添加到uiviewcontroller
1
A
回答
1
您需要從基於視圖的應用程序開始。然後在你的appDelegate文件中創建一個UITabbarController。
Appdelegate.h
UITabBarController *tabBarController;
// set properties
Appdelegate.m
// Synthsize
tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate=self;
//Adding Search,Nearby,Map,AboutUs,Favorites Tabs to tabBarController
Search * search = [[Search alloc] init];
UINavigationController *searchNav = [[UINavigationController alloc] initWithRootViewController:search];
Nearby* nearby = [[Nearby alloc] init];
UINavigationController *nearbyNav = [[UINavigationController alloc] initWithRootViewController:nearby];
Map* map = [[Map alloc] init];
UINavigationController *mapNav = [[UINavigationController alloc] initWithRootViewController:map];
AboutUs* aboutUs = [[AboutUs alloc] init];
UINavigationController *aboutUsNav = [[UINavigationController alloc] initWithRootViewController:aboutUs];
Favorites* favorites = [[Favorites alloc] init];
UINavigationController *favoritesNav = [[UINavigationController alloc] initWithRootViewController:favorites];
NSArray* controllers = [NSArray arrayWithObjects:searchNav,nearbyNav,mapNav,aboutUsNav,favoritesNav, nil];
tabBarController.viewControllers = controllers;
[window addSubview:tabBarController.view];
您可以相應地管理其標籤要放置導航控制器或只有一個視圖控制器。
在上述各你所提到的視圖控制器的然後需要實現
- (id)init {}
,可以在其中設置選項卡名稱和圖像。
+2
你好,通過[窗口addSubview :tabBarController.view];它會添加從firstview tabbar,但我想添加標籤欄來回第二視圖controller.Please幫助我。 – 2012-09-13 05:23:13
1
相關問題
- 1. 將UITabBarController添加到UIViewController
- 2. 將UITabBarController添加到UIViewController(Xcode 4.6)
- 3. 如何將uitabbarcontroller作爲子視圖添加到UIViewController中
- 4. 將UIViewController推送到UITabBarController
- 5. 如何將UITabBarController添加到窗口
- 6. 從UIViewcontroller加載UITabbarcontroller
- 7. 如何設置即將加載到UITabBarController中的UIViewController的屬性?
- 8. xcode 4.3.1 UITabBarController添加更多UIViewController
- 9. 如何將navigationViewController添加到UIViewController?
- 10. 如何將UIToolbar添加到UIViewController?
- 11. 如何將NavigationController添加到UIViewController?
- 12. 如何將子視圖添加到UIViewController?
- 13. 如何添加CTFrame到UIViewController?
- 14. 將SKScene添加到UIViewController?
- 15. 將UIToolbar添加到UIViewController
- 16. 將UIView添加到UIViewController
- 17. 將UIScrollView添加到UIViewController
- 18. 將uiview添加到uiviewcontroller
- 19. 在IOS中如何在特定的UIViewController中添加UITabBarController
- 20. 如何將UIViewController作爲子視圖添加到UIViewController(RootViewController)?
- 21. UINavigationBar添加到UITabBarController
- 22. Push從UITabbarController導航到UIViewController
- 23. 從UIViewController切換到UITabBarController
- 24. 切換意見 - UIViewController到UITabBarController
- 25. 如何添加圖像到UITabBarController
- 26. uitabbarcontroller + uitableviewcontroller + uiviewcontroller
- 27. UIViewController和UITabBARController
- 28. 將新的StoryBoard添加到UITabbarController
- 29. 在iOS上的UITabBarController下面添加UIViewController,如youtube應用程序
- 30. 添加UIview到UIViewController
您好,我有同樣的issue.Canü請幫助我ü是如何解決這個問題 – 2012-09-13 05:22:12