Sco*_*a P 2 iphone uitabbarcontroller
我目前在我的app委托中有一个UINavigationController,我将ViewController推送到登录.如果登录成功,我想创建一个带导航控制器的UITabBarController作为第一个Tab,其根控制器是我正在创建的UIViewController.
我的第一个UINavigationController的RootViewController实际上充当了logincontroller的委托,所以如果用户正确登录,它会在我的RootViewController中调用一个方法,然后我想把UITabBarController推到堆栈上.这是我的代码:
UITabBarController *tbController = [[UITabBarController alloc] init];
FileBrowserViewController *fileController = [[FileBrowserViewController alloc] init];
fileController.pathToFileDB = pathToDBUnzipped;
fileController.parentId = @"0";
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:fileController];
NSMutableArray *aViewControllersArray = [[NSMutableArray alloc] initWithCapacity:2];
[aViewControllersArray addObject:navController];
[navController release];
[tbController setViewControllers:aViewControllersArray];
[self.navigationController pushViewController:tbController animated:YES];
[tbController release];
Run Code Online (Sandbox Code Playgroud)
现在,一切正常.除了2件事.这是屏幕截图:

1)我看不到任何uitabbar项目.如何为每个标签设置图像和文本?2)我不想要那顶黑色的酒吧.我只想要一个带有撤销按钮的杆顶部.如何删除附加栏?
感谢您的帮助!
当我同时拥有UINavigationController和UITabbarController时,我总是遵循这种方法:
您需要从基于视图的应用程序开始.然后在appDelegate文件中创建一个UITabbarController.
Appdelegate.h
UITabBarController *tabBarController;
// set properties
Appdelegate.m
// Synthesize
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];
Run Code Online (Sandbox Code Playgroud)
因此,您可以管理要在哪个选项卡中放置导航控制器或仅放置视图控制器.
然后在上面提到的每个视图控制器中,您需要实现
- (id)init {}
Run Code Online (Sandbox Code Playgroud)
您可以在其中设置标签名称和图像.
我总是遵循这种方法,它永远不会失败.选项卡始终可见.您可以根据代码进行更改.
| 归档时间: |
|
| 查看次数: |
10224 次 |
| 最近记录: |