简体   繁体   English

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

[英]Every UIViewController with it's own Navigation bar inside uitabbar (iOS)

I am begineer to iOS application development. 我是iOS应用程序开发的初学者。

My Application flow is like that 我的申请流程就是这样

It starts as naviagtion controller then after detail page i make custom tab bar as window root controller 它从导航控制器开始,然后在详细信息页面之后将自定义选项卡栏作为窗口根控制器

now i have 3 tabs each tab with different ui 现在我有3个标签,每个标签具有不同的用户界面

means having 意味着有

tab1 -> table view tab1->表格视图

tab2 -> grid view tab2->网格视图

tab3 -> with multiple tables tab3->具有多个表

now i want each ui controller must have it's own navigation bar and also it crossponds to associate tab. 现在,我希望每个ui控制器必须具有自己的导航栏,并且也要交叉关联到“选项卡”。

Thank you for your precious opinion in advance. 预先感谢您的宝贵意见。

Just create the Custom tab bar controller with three navigation controller for 3 tabs. 只需使用三个用于三个选项卡的导航控制器创建“定制”选项卡栏控制器即可。

Then each navigation controller's root view controller should be your corresponding view controller. 然后,每个导航控制器的根视图控制器应该是您相应的视图控制器。

For better understanding please review this image. 为了更好地理解,请查看此图像。

在此处输入图片说明

Programmatically from Tabbarcontroller context 从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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM