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

65 篇文章 0 订阅
15 篇文章 0 订阅

一般我们

_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 都要自定义了 奶奶的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值