首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TabBar在iphone中不显示

问TabBar在iphone中不显示
EN

Stack Overflow用户
提问于 2013-01-03 18:53:19
回答 2查看 666关注 0票数 0

我正在使用to栏,当我导航到该控制器时,我的to栏不显示。

这是tabbar类的代码

代码语言:javascript
复制
UIViewController * myTruckDept= [[NYTTruckDeparture alloc]initWithSiteName:self.siteNam andSiteDate:self.date];
UIViewController * myEditionStates = [[NYTEditionStats alloc] initWithSiteName:self.siteName andSiteDate:self.date];
UIViewController * myPagingData = [[NYTPagingData alloc] initWithSiteName:self.siteName andSiteDate:self.date];
UIViewController * myDownTimeLog = [[NYTDowntimeLog alloc] initWithSiteName:self.siteName andSiteDate:self.date];
UIViewController * myComments = [[NYTComments alloc] initWithSiteName:self.siteName andSiteDate:self.date];

NSArray *array = [[NSArray alloc] initWithObjects:myTruckDept, myEditionStates, myPagingData, myDownTimeLog, myComments, nil];

self.viewControllersArray = array;
[self.view addSubview:myTruckDept.view];
self.selectedViewController = myTruckDept;
self.myTabBar.selectedItem=self.myTruckDeptTabBarItem;

当我将这个视图控制器推到导航控制器上时,当导航栏没有隐藏时,选项卡栏就会显示,当我隐藏导航栏并使用工具栏时,底部的选项卡栏就不会显示。

需要一个快速回复感谢提前。

EN

回答 2

Stack Overflow用户

发布于 2013-01-03 19:07:07

//定义UIViewControllers

代码语言:javascript
复制
UIViewController * myTruckDept= [[NYTTruckDeparture alloc]initWithSiteName:self.siteNam andSiteDate:self.date];
UIViewController * myEditionStates = [[NYTEditionStats alloc] initWithSiteName:self.siteName andSiteDate:self.date];
UIViewController * myPagingData = [[NYTPagingData alloc] initWithSiteName:self.siteName andSiteDate:self.date];
UIViewController * myDownTimeLog = [[NYTDowntimeLog alloc] initWithSiteName:self.siteName andSiteDate:self.date];
UIViewController * myComments = [[NYTComments alloc] initWithSiteName:self.siteName andSiteDate:self.date];

//在UINavigation控制器中添加视图

代码语言:javascript
复制
UINavigationController * myTruckDeptNavC = [[UINavigationController alloc] initWithRootViewController: myTruckDept];
UINavigationController *topyummsNavC = [[UINavigationController alloc] initWithRootViewController: myEditionStates];
UINavigationController *myEditionStatesNavC = [[UINavigationController alloc] initWithRootViewController: myPagingData];
UINavigationController * myDownTimeLogNavC = [[UINavigationController alloc] initWithRootViewController: myDownTimeLog];
UINavigationController * myCommentsNavC = [[UINavigationController alloc] initWithRootViewController:myComments];

//隐藏导航栏

代码语言:javascript
复制
myTruckDeptNavC.navigationBar.hidden = YES;
topyummsNavC .navigationBar.hidden = YES;
myEditionStatesNavC.navigationBar.hidden = YES;
myDownTimeLogNavC .navigationBar.hidden = YES;
myComments NavC.navigationBar.hidden = YES;

//初始化选项卡栏并设置控制器

代码语言:javascript
复制
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects: myTruckDeptNavC, topyummsNavC, myEditionStatesNavC ,myDownTimeLogNavC , myCommentsNavC, nil];
self.tabBarController.delegate = self;

//呈现UITable栏

代码语言:javascript
复制
[self.window.rootViewController presentModalViewController:self.tabBarController animated:animated];

希望这能帮上大忙。

票数 0
EN

Stack Overflow用户

发布于 2013-01-03 19:08:12

尝试使用此代码来创建Custom tabbarController。在这里,我创建了两个,你可以很容易地使它4。

要了解更多信息,请查看我的答案:iOS code optimization

代码语言:javascript
复制
tabBar_Controller = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray =[[NSMutableArray alloc]initWithCapacity:2];


firstViewController = [[FirstViewController alloc] initWithSiteName:self.siteNam andSiteDate:self.date];
nav = [[UINavigationController alloc] initWithRootViewController:firstViewController];
nav.tabBarItem.title = @"item1";
nav.navigationBar.barStyle = UIBarStyleBlack;
nav.navigationBar.hidden = YES;
[localControllersArray addObject:nav];
[self setNav:nil];

secondViewController = [[SecondViewController alloc] initWithSiteName:self.siteNam andSiteDate:self.date];
nav = [[UINavigationController alloc]initWithRootViewController:secondViewController];
nav.navigationBar.hidden = YES;
nav.tabBarItem.title = @"item2";
[localControllersArray addObject:nav];
[self setNav:nil];

tabBar_Controller.viewControllers = localControllersArray;
tabBar_Controller.delegate = self;
tabBar_Controller.selectedIndex = 0;
[self.window addSubview:tabBar_Controller.view];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14137441

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档