[iOS 导航与TabBar混合] UINavigationCon+UITabBarViewController 混合使用

news/2024/7/20 20:01:38 标签: ios, 应用, 导航, tabBarCont, roller

一般我们

_window.rootViewController = ???

都是用一个根导航控制器
说白了, 其实整个app里面 就有一个导航控制器

如果 _window.rootViewController = 是TabBarControllerd 的子类 呢?

我这里记录下写法,仅供自己翻阅

AppDelegate.m


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [IQKeyboardManager sharedManager];



    PayViewController *payC = [[PayViewController alloc] init];
    PayNavigationController *payNav = [[PayNavigationController alloc] initWithRootViewController:payC];
    payNav.tabBarItem.image = [UIImage imageNamed:@"缴费-正常"];
    payNav.tabBarItem.selectedImage = [UIImage imageNamed:@"缴费-选中"];

    SearchViewController *searchC = [[SearchViewController alloc] init];
    SearchNavigationController *sarchNav = [[SearchNavigationController alloc] initWithRootViewController:searchC];
    sarchNav.tabBarItem.image = [UIImage imageNamed:@"查询-正常"];
    sarchNav.tabBarItem.selectedImage = [UIImage imageNamed:@"查询-选中"];


    AccountViewController *accountC = [[AccountViewController alloc] init];
    AccountNavigationController *accountNav = [[AccountNavigationController alloc] initWithRootViewController:accountC];
    accountNav.tabBarItem.image = [UIImage imageNamed:@"我的-正常"];
    accountNav.tabBarItem.selectedImage = [UIImage imageNamed:@"账户-选中"];


    FlowCardBarController *tabBarC = [[FlowCardBarController alloc] init];
    tabBarC.viewControllers = @[payNav,sarchNav,accountNav];
    tabBarC.tabBarController.view.height = 140;


    _window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    _window.rootViewController = tabBarC;
    [_window makeKeyWindow];

    return YES;
}

我想应该很明白, 首先我有三个ViewController 作为视图
其次, 我使用三个继承自UINavigationController导航控制器,
让这三个视图控制器 分别 加入到 三个 导航控制器中.

让 _window.rootViewController = tabBarC;
于是,我们就得到这个GIf
这里写图片描述

然后,我们给上图的按钮们(bottom1,bottom2,bottom3,bottom4) 分别添加方法,让他们分别push到各自的视图中,从而验证我的疑惑,
目前,我拥有三个导航控制器了,他们如果各自push 那么各自的导航条肯定不变,各自管各自的

就像这样

这里写图片描述
[备注:由于没录制到 bottom1的时候 是进入红色的,特此说明]

那么,如果我用Bottom4来实现, 导航1 push 到导航2 下面的控制器,会出现什么情况???

情形如下

这里写图片描述

看到,不管是什么viewCOntroller 只要从各自的导航push过去,那么 此viewController导航控制器就是来自上一个,

不会因为之前被push过以后而 保持以前的样式,

因此,我感觉 如果以TabBarController 为RootViewController

那么,里面的每一项 都应该是 各自管各自的 不然, 会不会混乱啊“` 哈哈 自己的猜想

最后,蛋疼的事情来了, 我从设计那边拿来的图 自带文字, 尺寸并不标准,so. 连tabBarViewController 都要自定义了 奶奶的


http://www.niftyadmin.cn/n/1557620.html

相关文章

react onClick自执行问题与react绑定事件的几种方式比较(性能与优缺点)

写组件的时候发现子组件的onClick方法自动执行了,代码如下: let columns[ {title:"姓名",width:"150",dataIndex:"name" }, {title:"年龄",width:"150",dataIndex:"age" }, {title:"菜单权限&qu…

[iOSTabBarController自定义] 关联控制器和按钮的方法就是 selectedIndex = tag

如何自定义TabbarController 看这里 上面是个详细的帖子 自定义TabBar 首先 一直有个困惑,就是 当删除了 UITabBarController 的 [self.tabBar removeFromSuperview]; 之后,我们通常都会自己创建一个 tabBar的view 或者是 image 图片 然后,在这个 view 或者imageView 上…

react-antd table树形数据默认展开行实现以及自定义图标实现及踩坑(defaultExpandedRowKeys,expandedRowKeys)

前言: 最近在做一个权限管理的后台项目,经常涉及到树形数据展示,就用到了antd,table表格树形数据组件。记录一下使用过程的坑。 环境及配置: antd -3.23.6(大版本为antd 3) 官方antd 3版本API文档 antd 3和antd 4…

中琅领跑条码打印软件打开时找不到Sentinel锁的解决方案

在使用中琅领跑条码打印软件的过程中有些朋友可能会遇到这样的问题:昨天用着好好的,今天一打开缺报错了,错误信息为“未找到Sentinel锁,请联系官网www.ew8.cn寻求帮助!(H0007)”。为什么会出现这…

css display:“inline-block“错位问题与css超出部分显示省略号

前言&#xff1a; 最近在做超出部分以...显示&#xff0c;遇到的问题记录一下。 一、超出部分用三个点&#xff08;...&#xff09;显示实现 切记需要给容器设置width树形 1.单行实现 <!doctype html> <html lang"en"> <head><meta charse…

[iOS 上传AppStore] 上传AppStore报的一些错汇总:

最近上架AppStore 项目中有大坑 一个多少年前的老第三方库不支持64位 在xocde工程工程中添加arm64之后,开始报错,(只能换第三方) 下面列举上传AppStore中的错误 ,仅供自己参考 -90032 error (plist存在一些文件没找到) http://blog.csdn.net/lookplane/article/details/5…

前端leader找我谈心:我是如何从刚毕业的前端菜鸟一步步成长为前端工程师的?...

谈谈学习 我做前端已经有五年的时间了&#xff0c;从大学刚毕业的时候&#xff0c;我是一个完全什么都不懂的小白。虽然我大学里学的是软件工程专业&#xff0c;但是因为在大学里荒废学业&#xff0c;每天只知道打游戏&#xff0c;基本上到大学毕业之前我是什么都不会的&#x…

ie浏览器报strict模式下一个属性不能定义多次

前言&#xff1a; 最近在做项目&#xff0c;要兼容ie11&#xff08;11还是挺好兼容的&#xff09;&#xff0c;但还是出现一些报错&#xff0c;记录一下。 报错信息&#xff1a; strict模式下一个属性不能定义多次 这个很好理解就是某个属性定义了多次&#xff08;ie有这个…