本文介绍了不显示 tabBarController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想以编程方式制作 tabbarcontroller
.tabBarController
未显示在页面中.谁能告诉我们哪里出了问题.我们可以在一个应用程序中创建多个 tabbarcontroller
i want to make tabbarcontroller
programatically. The tabBarController
is not displayed in the page. can anyone tell that whts going wrong.and can we make more than one tabbarcontroller
in an application
ViewController.m
- (void)viewDidLoad
{
report=[[UIViewController alloc]initWithNibName:@"ViewController" bundle:nil];
View1 *template=[[View1 alloc]initWithNibName:@"View1" bundle:nil];
View2 *acc=[[View2 alloc]initWithNibName:@"View2" bundle:nil];
View3 *four=[[View3 alloc]initWithNibName:@"View3" bundle:nil];
View4 *five=[[View4 alloc]initWithNibName:@"View4" bundle:nil];
nav1=[[UINavigationController alloc]initWithRootViewController:report];
nav2=[[UINavigationController alloc]initWithRootViewController:template];
nav3=[[UINavigationController alloc]initWithRootViewController: acc];
nav4=[[UINavigationController alloc]initWithRootViewController:four];
nav5=[[UINavigationController alloc]initWithRootViewController:five];
UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@"Title" image:[UIImage imageNamed:@"singleicon.png"] tag:0];
UITabBarItem *item1 = [[UITabBarItem alloc] initWithTitle:@"Reports" image:[UIImage imageNamed:@"doubleicon.png"] tag:1];
UITabBarItem *item2 = [[UITabBarItem alloc] initWithTitle:@" New " image:[UIImage imageNamed:@"clockicon.png"] tag:2];
UITabBarItem *item3=[[UITabBarItem alloc]initWithTitle:@"four" image:[UIImage imageNamed:@"dependenticon.png"] tag:3];
UITabBarItem *item4=[[UITabBarItem alloc]initWithTitle:@"five" image:[UIImage imageNamed:@"toolicon.png"] tag:4];
nav1.tabBarItem = item;
nav2.tabBarItem = item1;
nav3.tabBarItem = item2;
nav4.tabBarItem=item3;
nav5.tabBarItem=item4;
//[item1 setBadge:@"25"];
self.tabBarController=[[UITabBarController alloc]init];
[self.tabBarController setViewControllers:[NSArray arrayWithObjects:nav1,nav2,nav3,nav4,nav5,nil]];
self.report = self.tabBarController;
// [self.report makeKeyAndVisible];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
推荐答案
我就是这样做的
[self.navigationController pushViewController:tabBarController animated:YES];
这篇关于不显示 tabBarController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!