请参阅此代码,它提供了 2 个带导航的标签栏。在AppDelegate.h
请声明
UINavigationController *nav1;
UINavigationController *nav2;
UITabBarController *tab;
在Appdelegate.m
,didFinishLaunchingWithOptions
请添加:-
tab = [[UITabBarController alloc]init];
ViewController *view1 = [[ViewController alloc]init];
nav1= [[UINavigationController alloc]initWithRootViewController:view1];
UITabBarItem *tab1 = [[UITabBarItem alloc]initWithTitle:@"Add" image:[UIImage imageNamed:@"Plus.png"] tag:1];
view1.title = @"Add";
[view1 setTabBarItem:tab1];
SettingsViewController *view2 = [[SettingsViewController alloc]init];
nav2= [[UINavigationController alloc]initWithRootViewController:view2];
UITabBarItem *tab2 = [[UITabBarItem alloc]initWithTitle:@"Setting" image:[UIImage imageNamed:@"settings.png"] tag:2];
view2.title = @"Setting";
[view2 setTabBarItem:tab2];
tab.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nil];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = tab;
还要检查此链接以进一步实施...希望这会有所帮助:)
UItabBar 改变视图控制器