每个UIViewController都有自己的导航栏,位于uitabbar(iOS)中

时间:2014-11-25 12:11:10

标签: ios uitableview uinavigationbar uitabbar

我是iOS应用程序开发的初学者。

我的申请流程就像那样

它以naviagtion控制器开始,然后在详细页面后我将自定义标签栏设置为窗口根控制器

现在我有3个标签 每个标签都有不同的ui

意味着

tab1 - >表格视图

tab2 - >网格视图

tab3 - >多个表格

现在我希望每个ui控制器都必须拥有它自己的导航栏 并且它也会交叉到关联标签。

提前感谢您的宝贵意见。

1 个答案:

答案 0 :(得分:0)

只需使用三个选项卡的三个导航控制器创建自定义选项卡栏控制器。

然后每个导航控制器的根视图控制器应该是您对应的视图控制器。

为了更好地理解,请查看此图片。

enter image description here

以编程方式从Tabbarcontroller上下文

UINavigationController *navCont1;
UINavigationController *navCont2;

UITabBarController *yourTabbarcontroller;

yourTabbarcontroller = [[UITabBarController alloc]init];




FirstViewController *viewCont1 = [[FirstViewController alloc]init];

navCont1= [[UINavigationController alloc]initWithRootViewController:viewCont1];

UITabBarItem *tab1 = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:1];

[viewCont1 setTabBarItem:tab1];



SecondViewController *viewCont2 = [[SecondViewController alloc]init];

navCont2= [[UINavigationController alloc]initWithRootViewController:viewCont2];

UITabBarItem *tab2 = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:2];

[viewCont2 setTabBarItem:tab2];



tab.viewControllers = [NSArray arrayWithObjects:navCont1,navnavCont2,nil];

self.window.rootViewController = tab;