【发布时间】:2011-09-01 16:49:33
【问题描述】:
我有一个基于视图的应用程序,其中在第一个视图中我不想要标签栏控制器,而从其他视图(即来自第二个视图..)我想要标签栏控制器。 我用谷歌搜索了它,但找不到解决方案。
【问题讨论】:
-
你好,我也遇到了同样的问题。你能帮我解决这个问题吗
标签: iphone xcode uiview uitabbarcontroller
我有一个基于视图的应用程序,其中在第一个视图中我不想要标签栏控制器,而从其他视图(即来自第二个视图..)我想要标签栏控制器。 我用谷歌搜索了它,但找不到解决方案。
【问题讨论】:
标签: iphone xcode uiview uitabbarcontroller
您需要从基于视图的应用程序开始。然后在你的 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 {}
您可以在其中设置选项卡名称和图像。
【讨论】: