UINavigationController与UITabBarController相关问题
相关 问题
2023-09-14 08:57:58 时间
UINavigationController与UITabBarController相关问题
UINavigationController与UITabBarController混用是非常常见的,有时候会遇到UINavigationController推出(push)出controller后隐藏UITabBarController的问题,很容易对吧.
源码如下:
// // AppDelegate.m // NavigationController // Copyright (c) 2014年 Y.X. All rights reserved. #import "AppDelegate.h" #import "RootViewController.h" #define CreateNavigationControllerWith(controller) \ [[UINavigationController alloc] initWithRootViewController:controller] @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // 初始化导航栏控制器 UINavigationController *newProductNC = \ CreateNavigationControllerWith([RootViewController new]); // 初始化TabBarController UITabBarController *rootBC = [[UITabBarController alloc] init]; rootBC.viewControllers = @[newProductNC]; // 交给系统管理 self.window.rootViewController = rootBC; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; @end
// // RootViewController.m // NavigationController // Copyright (c) 2014年 Y.X. All rights reserved. #import "RootViewController.h" #import "SecondViewController.h" @interface RootViewController () @implementation RootViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) self.title = @"YouXianMing"; return self; - (void)viewDidLoad [super viewDidLoad]; // 设定背景色 self.view.backgroundColor = [UIColor whiteColor]; // 点击手势 UITapGestureRecognizer *tapGesture = \ [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapEvent:)]; // 添加手势 [self.view addGestureRecognizer:tapGesture]; - (void)tapEvent:(UIGestureRecognizer *)sender [self.navigationController pushViewController:[SecondViewController new] animated:YES]; @end
// // SecondViewController.m // NavigationController // Copyright (c) 2014年 Y.X. All rights reserved. #import "SecondViewController.h" @interface SecondViewController () @implementation SecondViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) return self; - (void)viewDidLoad [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; @end
效果:
将RootViewController.m中tapEvent:修改一下,如下所示:
效果(注意看底部的隐藏效果哦):
注意:隐藏与取消隐藏是成对出现的.
附录:
-修改系统颜色样式-
http://stackoverflow.com/questions/19504291/changing-the-tint-color-of-uibarbuttonitem
相关文章
- VSCode插件Remote-SSH相关问题
- Git-命令速查与相关问题解决-Cheatsheet & Troubleshooting
- Python(二)Marshmallow 库相关学习
- Java 中 String 相关问题
- Webpack相关基础
- 机器人工程相关课程共性问题的思考-2022-
- @Configuration 相关依赖注入问题
- 请收下这 10 个安全相关的开源项目
- JavaScript刷LeetCode拿offer-栈相关题目
- 汇总一些不错的嵌入式相关的公司
- 【错误记录】Flutter 环境安装相关问题 ( 执行 flutter doctor 命令后续错误处理 )
- Redis相关面试问题
- SQLServer 错误 18752 一次只能有一个日志读取器代理或日志相关过程(sp_repldone、sp_replcmds 和 sp_replshowcmds)连接到某个数据库。 如果执行了一个日志相关过程,那么在启动日志读取器代理或者执行另一个日志相关过程之前,请删除执行第一个过程时所用的连接,或者在该连接上执行 sp_replflush。 故障 处理 修复 支持远程
- 浅析Mongodb性能优化的相关问题
- 美团订单推荐相关专利获授权,可解决无法取消订单导致用户体验差的问题
- 特斯拉专利数量580多项:远超竞争对手 计算机技术相关专利增长快
- 小米副总裁解答铁蛋相关问题 除了卖萌还能人脸识别
- ASP操作Excel相关技术总结
- Oracle存储过程总结二、字符串处理相关函数
- oracle安装出现乱码等相关问题
- C#启动windows服务方法的相关问题分析
- 基于Java数组内存分配的相关问题
- 基于HBaseThrift接口的一些使用问题及相关注意事项的详解
- C/C++中指针和引用之相关问题深入研究
- 巧用jquery解决下拉菜单被Div遮挡的相关问题
- 如何搜索查找并解决Django相关的问题