当前位置:网站首页>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
边栏推荐
- Principle analysis and source code interpretation of service discovery
- 莫队学习笔记(一)
- Server and client dual authentication (2)
- Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
- 服务器环境配置全过程
- 在同一conda环境下先装Pytroch后装TensorFlow
- JS judge the data types object.prototype.tostring.call and typeof
- Keeping alive to realize MySQL automatic failover
- 【Datawhale】【机器学习】糖尿病遗传风险检测挑战赛
- Add DLL
猜你喜欢

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

Server and client dual authentication (2)

Gauss elimination

Redis sentinel mode setup under Windows

Matlab Simulink realizes fuzzy PID control of time-delay temperature control system of central air conditioning

挡不住了,纯国产PC已就位,美国的软硬件体系垄断正式被破

2021 windows penetration of "Cyberspace Security" B module of Shandong secondary vocational group (analysis)

Gauss elimination solves the inverse of matrix (Gauss)

Uni app learning summary

Xiaobai makes a wave of deep copy and shallow copy
随机推荐
IIS website configuration
Gauss elimination for solving XOR linear equations
asp. Net using redis cache (2)
SSG框架Gatsby访问数据库,并显示到页面上
网站设计需要的基本知识
服务器、客户端双认证
QT handy notes (VI) -- update interface, screenshot, file dialog box
QT handy notes (II) edit control and float, qstring conversion
Mo team learning summary (II)
POJ 1012 Joseph
Cloud native (36) | introduction and installation of harbor in kubernetes
在同一conda环境下先装Pytroch后装TensorFlow
官方颁发的SSL证书与自签名证书结合实现网站双向认证
uni-app学习总结
Write a script that can run in Bash / shell and PowerShell
copyTo
AR model in MATLAB for short-term traffic flow prediction
Network flow learning notes
一种分布式深度学习编程新范式:Global Tensor
QT随手笔记(六)——更新界面、截图、文件对话框