当前位置:网站首页>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
边栏推荐
- 高斯消元求解异或线性方程组
- Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
- copyTo
- Antd treeselect gets the value of the parent node
- mfc随手笔记
- Phpexcel export Emoji symbol error
- 一种分布式深度学习编程新范式:Global Tensor
- 2021年山东省中职组“网络空间安全”B模块windows渗透(解析)
- Xiaobai makes a wave of deep copy and shallow copy
- QT handy notes (III) use qtcharts to draw a line chart in VS
猜你喜欢
Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
Gauss elimination
小白搞一波深拷贝 浅拷贝
AR model in MATLAB for short-term traffic flow prediction
I finished watching this video on my knees at station B
2021 windows penetration of "Cyberspace Security" B module of Shandong secondary vocational group (analysis)
开发转测试:从0开始的6年自动化之路...
面试突击68:为什么 TCP 需要 3 次握手?
Qt随手笔记(三)在vs中使用QtCharts画折线图
Spolicy request case
随机推荐
Spolicy request case
In the same CONDA environment, install pytroch first and then tensorflow
QT handy notes (III) use qtcharts to draw a line chart in VS
解决IE7 & IE8 存储cookie问题
Node 内存溢出及V8垃圾回收机制
POJ 1012 Joseph
Malloc failed to allocate space and did not return null
A new paradigm of distributed deep learning programming: Global tensor
【信息系统项目管理师】初见高项系列精华汇总
Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration
莫队学习笔记(一)
JS one line code to obtain the maximum and minimum values of the array
Mqtt x cli officially released: powerful and easy-to-use mqtt 5.0 command line tool
JS 一行代码 获取数组最大值与最小值
Explain automatic packing and unpacking?
Apple dominates, Samsung revives, and domestic mobile phones fail in the high-end market
2019 ICPC Asia Yinchuan regional (water problem solution)
Alibaba cloud technology expert haochendong: cloud observability - problem discovery and positioning practice
Simple pedestrian recognition code to 88% accuracy Zheng Zhedong preparation
C managed and unmanaged