当前位置:网站首页>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
边栏推荐
- Simple pedestrian recognition code to 88% accuracy Zheng Zhedong preparation
- ie7设置overflow属性失效解决方法
- regular expression
- m进制数str转n进制数
- Explain automatic packing and unpacking?
- Show default image when wechat applet image cannot be displayed
- 在同一conda环境下先装Pytroch后装TensorFlow
- Global variables in DLL
- 面试突击68:为什么 TCP 需要 3 次握手?
- QT随手笔记(六)——更新界面、截图、文件对话框
猜你喜欢

Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)

Search module use case writing

Qt随手笔记(三)在vs中使用QtCharts画折线图
![[datawhale] [machine learning] Diabetes genetic risk detection challenge](/img/98/7981af7948feb73168e5200b3dfac9.png)
[datawhale] [machine learning] Diabetes genetic risk detection challenge

Login module use case writing

SSG framework Gatsby accesses the database and displays it on the page

解决ProxyError: Conda cannot proceed due to an error in your proxy configuration.

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

Alibaba cloud technology expert haochendong: cloud observability - problem discovery and positioning practice

Gauss elimination solves the inverse of matrix (Gauss)
随机推荐
Flutter Event 派发
【荧光字效果】
云原生(三十六) | Kubernetes篇之Harbor入门和安装
Node 内存溢出及V8垃圾回收机制
挡不住了,纯国产PC已就位,美国的软硬件体系垄断正式被破
Explain automatic packing and unpacking?
Flutter event distribution
新公链Aptos何以拉满市场期待值?
Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration
2021年山东省中职组“网络空间安全”B模块windows渗透(解析)
MySQL的逻辑架构
Registration module use case writing
mfc随手笔记
JS judge the data types object.prototype.tostring.call and typeof
C managed and unmanaged
Interpretation of the standard of software programming level examination for teenagers_ second level
Antd treeselect gets the value of the parent node
EOJ 2020 January race E-number transformation
Gauss elimination for solving XOR linear equations
asp. Net using redis cache (2)