当前位置:网站首页>tabbarController的使用
tabbarController的使用
2022-07-26 09:22:00 【~轻舟~】
做一个简单的tabbarController大体分为三步:
//1.创建标签控制器
UITabBarController *tab = [[UITabBarController alloc] init];
//2.创建相应的字控制器
ViewController *firstVc = [[ViewController alloc] init];
firstVc.tabBarItem.title = @"你好";
firstVc.tabBarItem.image = [UIImage imageNamed:@"萌萌"];
SecondViewController *secondVC = [[SecondViewController alloc] init];
secondVC.tabBarItem.title = @"hello";
secondVC.tabBarItem.image = UIImageName(@"记忆");
//3.添加到控制器
NSArray *array = @[firstVc,secondVC];
tab.viewControllers = array;
self.window.rootViewController = tab;
[self.window makeKeyAndVisible];
这样的话,一个简单的tabbarController就出来了
一般呢有Tabbar也会带有navgationBar所以今天我也将navgationbar也加上吧 看下面的代码:
//1.创建标签控制器
UITabBarController *tab = [[UITabBarController alloc] init];
//2.创建相应的字控制器
ViewController *firstVc = [[ViewController alloc] init];
//2.1这里加了nav的title
firstVc.navigationItem.title = @"你好";
firstVc.tabBarItem.title = @"你好";
firstVc.tabBarItem.image = [UIImage imageNamed:@"萌萌"];
//2.2这里初始化nav且设置rootVC
UINavigationController *firstNav = [[UINavigationController alloc] initWithRootViewController:firstVc];
SecondViewController *secondVC = [[SecondViewController alloc] init];
secondVC.navigationItem.title = @"hello";
secondVC.tabBarItem.title = @"hello";
secondVC.tabBarItem.image = UIImageName(@"记忆");
UINavigationController *secondNav = [[UINavigationController alloc] initWithRootViewController:secondVC];
//3.添加到控制器
//特别注意:管理一组的控制器(最多显示五个,多于五个的包括五个全部在更多模块,并且可以通过拖拽的方式进行顺序编辑);
// NSArray *array = @[firstVc,secondVC];
//将数组中的控制器换掉 就搞定了
NSArray *array = @[firstNav,secondNav];
tab.viewControllers = array;
self.window.rootViewController = tab;
[self.window makeKeyAndVisible];
这只是低级的实现方法 下一篇 封装
边栏推荐
- 省政府召开全省高温天气安全防范工作电视电话会议
- Force button list question
- 设置视图动态图片
- 2022 Shanghai safety officer C certificate examination questions and mock examination
- Object 的Wait Notify NotifyAll 源码解析
- Processing of inconsistent week values obtained by PHP and MySQL
- Arc GIS basic operation 3
- 2B and 2C
- 838. Heap sorting
- ZXing简化版,转载
猜你喜欢

arcgis的基本使用1

Bloom filter

JS output diamond on the console

多项式开根

Zipkin installation and use

Stm32+mfrc522 completes IC card number reading, password modification, data reading and writing

Redis principle and use - Basic Features

js在控制台输出菱形

Windows backs up the database locally by command

Study notes of dataX
随机推荐
Mysql事务
Object type collections are de duplicated according to the value of an attribute
Under a directory of ext3 file system, subfolders cannot be created, but files can be created
暑假第四周
Local cache
Error: Cannot find module ‘umi‘ 问题处理
吴恩达机器学习之线性回归
JVM command induction
【Mysql】redo log,undo log 和binlog详解(四)
Your login IP is not within the login mask configured by the administrator
js中树与数组的相互转化(树的子节点若为空隐藏children字段)
2B and 2C
MySQL 强化知识点
Basic use of ArcGIS 4
STM32+MFRC522完成IC卡号读取、密码修改、数据读写
Polynomial open root
What are CSDN spaces represented by
JS - DataTables control on the number of displays per page
【Mysql】Mysql锁详解(三)
el-table的formatter属性的用法