当前位置:网站首页>Use of tabbarcontroller
Use of tabbarcontroller
2022-07-26 09:49:00 【~ light boat ~】
Make a simple one tabbarController There are three steps :
//1. Create label controller
UITabBarController *tab = [[UITabBarController alloc] init];
//2. Create the corresponding word controller
ViewController *firstVc = [[ViewController alloc] init];
firstVc.tabBarItem.title = @" Hello ";
firstVc.tabBarItem.image = [UIImage imageNamed:@" Adorable adorable "];
SecondViewController *secondVC = [[SecondViewController alloc] init];
secondVC.tabBarItem.title = @"hello";
secondVC.tabBarItem.image = UIImageName(@" memory ");
//3. Add to controller
NSArray *array = @[firstVc,secondVC];
tab.viewControllers = array;
self.window.rootViewController = tab;
[self.window makeKeyAndVisible];
In this case , A simple tabbarController It's coming out. 
Generally, yes Tabbar It also carries navgationBar So today I will also navgationbar Add in, too Look at the code below :
//1. Create label controller
UITabBarController *tab = [[UITabBarController alloc] init];
//2. Create the corresponding word controller
ViewController *firstVc = [[ViewController alloc] init];
//2.1 It's added here nav Of title
firstVc.navigationItem.title = @" Hello ";
firstVc.tabBarItem.title = @" Hello ";
firstVc.tabBarItem.image = [UIImage imageNamed:@" Adorable adorable "];
//2.2 Initialization here nav And set rootVC
UINavigationController *firstNav = [[UINavigationController alloc] initWithRootViewController:firstVc];
SecondViewController *secondVC = [[SecondViewController alloc] init];
secondVC.navigationItem.title = @"hello";
secondVC.tabBarItem.title = @"hello";
secondVC.tabBarItem.image = UIImageName(@" memory ");
UINavigationController *secondNav = [[UINavigationController alloc] initWithRootViewController:secondVC];
//3. Add to controller
// Particular attention : Manage a group of controllers ( Display up to five , More than five include five all in more modules , And it can be edited sequentially by dragging );
// NSArray *array = @[firstVc,secondVC];
// Replace the controller in the array Just like the
NSArray *array = @[firstNav,secondNav];
tab.viewControllers = array;
self.window.rootViewController = tab;
[self.window makeKeyAndVisible];
This is just a low-level implementation Next encapsulation
边栏推荐
- 【荧光字效果】
- 小白搞一波深拷贝 浅拷贝
- Application of Gauss elimination
- Flutter event distribution
- MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具
- Use of OpenCV class
- Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken
- ie7设置overflow属性失效解决方法
- 网站设计需要的基本知识
- SSG framework Gatsby accesses the database and displays it on the page
猜你喜欢

CSV data file settings of JMeter configuration components

服务器、客户端双认证(2)

MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具

面试突击68:为什么 TCP 需要 3 次握手?

Xiaobai makes a wave of deep copy and shallow copy

图解用户登录验证流程,写得太好了!

matlab中的AR模型短时预测交通流

The problem of accessing certsrv after configuring ADCs

Registration module use case writing

SSG框架Gatsby访问数据库,并显示到页面上
随机推荐
M-ary number STR to n-ary number
matlab中的AR模型短时预测交通流
Sqoop [environment setup 01] CentOS Linux release 7.5 installation configuration sqoop-1.4.7 resolve warnings and verify (attach sqoop 1 + sqoop 2 Latest installation package +mysql driver package res
Apple dominates, Samsung revives, and domestic mobile phones fail in the high-end market
Learning notes: what are the common array APIs that change the original array or do not change the original array?
服务器、客户端双认证(2)
2019 ICPC Asia Yinchuan regional (water problem solution)
解决ProxyError: Conda cannot proceed due to an error in your proxy configuration.
[fluorescent character effect]
C managed and unmanaged
EOJ 2020 1月月赛 E数的变换
Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken
What is the principle of reflection mechanism?
QT handy notes (III) use qtcharts to draw a line chart in VS
高斯消元的应用
EOJ 2020 January race E-number transformation
Simple pedestrian recognition code to 88% accuracy Zheng Zhedong preparation
开发转测试:从0开始的6年自动化之路...
Mo team learning summary (II)
Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration