UINavigationController和UITabBarController合用
一、创建一个 Tabbed Application.默认创建的是带有两个Tab的工程。
二、在AppDelegate.h里面添加
- @property (strong, nonatomic) UINavigationController *NaviView1Controller;
- @property (strong, nonatomic) UINavigationController *NaviView2Controller;
三、修改AppDelegate.m文件的didFinishLaunchingWithOptions函数,在这里我们设置相应的UINavigationController.
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
- // Override point for customization after application launch.
- UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
- UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];
- self.tabBarController = [[[UITabBarController alloc] init] autorelease];
- self.tabBarController.viewControllers = @[viewController1, viewController2];
- self.window.rootViewController = self.tabBarController;
- [self.window makeKeyAndVisible];
- return YES;
- }
修改后:
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
- // Override point for customization after application launch.
- UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
- viewController1.title = @"View1";
- self.NaviView1Controller = [[[UINavigationController alloc] initWithRootViewController:viewController1] autorelease];
- UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];
- viewController2.title = @"View2";
- self.NaviView2Controller = [[[UINavigationController alloc] initWithRootViewController:viewController2] autorelease];
- self.tabBarController = [[[UITabBarController alloc] init] autorelease];
- self.tabBarController.viewControllers = @[self.NaviView1Controller, self.NaviView2Controller];
- self.window.rootViewController = self.tabBarController;
- [self.window makeKeyAndVisible];
- return YES;
- }
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
- // Override point for customization after application launch.
- UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
- viewController1.title = @"View1";
- self.NaviView1Controller = [[[UINavigationController alloc] initWithRootViewController:viewController1] autorelease];
- UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];
- viewController2.title = @"View2";
- self.NaviView2Controller = [[[UINavigationController alloc] initWithRootViewController:viewController2] autorelease];
- self.tabBarController = [[[UITabBarController alloc] init] autorelease];
- self.tabBarController.viewControllers = @[self.NaviView1Controller, self.NaviView2Controller];
- self.window.rootViewController = self.tabBarController;
- [self.window makeKeyAndVisible];
- return YES;
- }
UINavigationController和UITabBarController合用的更多相关文章
- iOS开发——实战OC篇&环境搭建之Xib(玩转UINavigationController与UITabBarController)
iOS开发——实战OC篇&环境搭建之Xib(玩转UINavigationController与UITabBarController) 前面我们介绍了StoryBoard这个新技术,和纯技术 ...
- iOS开发——实战OC篇&环境搭建之纯代码(玩转UINavigationController与UITabBarController)
iOS开发——实战OC篇&环境搭建之纯代码(玩转UINavigationController与UITabBarController) 这里我们就直接上实例: 一:新建一个项目singleV ...
- iOS开发——实战OC篇&环境搭建之StoryBoard(玩转UINavigationController与UITabBarController)
环境搭建之StoryBoard(玩转UINavigationController与UITabBarController) 研究了这么就IOS开发,都没有所处一个像样或者自己忙一点的项目.最近自 ...
- UIViewController、UINavigationController与UITabBarController的整合使用
UINavigationController与UITabBarController是iOS开发中最常用的两种视图控制器,它们都属于UIViewController的子类,继承关系如下: @interf ...
- UINavigationController与UITabBarController相关问题
UINavigationController与UITabBarController相关问题 UINavigationController与UITabBarController混用是非常常见的,有时候会 ...
- UINavigationController和UITabBarController
UINavigationController和UITabBarController 目录 概述 UINavigationController UITabBarController 实用功能 待解决 概 ...
- UINavigationController与UITabbarController的样式
之前虽然也手写过这两中视图控制器,但是更多的还是使用SB来创建,最近发现了一些问题,现在总结一下. 1.改变UINavigationBar的颜色 在UINavigationController中,之前 ...
- UINavigationController 与 UITabBarController
http://www.cnblogs.com/YouXianMing/p/3756904.html // index start from 1. UITabBarItem *newsItem = [[ ...
- UINavigationController 和 UITabBarController
UINavigationController当设置根控制器的时候,意思就是把根控制器压入栈内,当我们push的时候,我们把下一个控制器压入栈内,当我们pop的时候把上面的控制器的内存释放 UITa ...
随机推荐
- Hacker(三)之黑客定位目标---IP
IP即Internet Protocol的简称,中文简称"网协",是为计算机网络相互连接进行通信而设计的协议.无论何种操作系统,只要遵守IP协议就可以与Internet互联互通. ...
- DropDownList 绑定数据后 插入一条不属于表中的数据
ddlFGiftId.DataSource = dtGift; ddlFGiftId.DataTextField = "FGiftName"; ddlFGiftId.DataVal ...
- 使用SqlBulkCopy批量插入数据
static void Main(string[] args) { //定义与目标表结构相同的DataTable DataTable dataTable = new DataTable(); data ...
- CentOS 7 U盘安装解决找不到U盘问题
在使用U盘进入CentOS7系统安装选项时,按下Tab键,在屏幕下方出现:vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x ...
- locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory
安装好CentOS后,第一次进入系统使用locate命令,结果出现:locate: can not stat () `/var/lib/mlocate/mlocate.db': No such fil ...
- struts2之chain的使用
/** * 实现功能表单提交给action1先处理,再交由action2进行处理,中间传递参数a,b **/ /** * 1. 配置文件 **/ <action name="actio ...
- GPS数据处理 - 字符串函数的灵活应用
题目内容: NMEA- 0183协议是为了在不同的GPS(全球定位系统)导航设备中建立统一的BTCM(海事无线电技术委员会)标准,由美国国家海洋电子协会(NMEA- The National Mari ...
- [zz]npm安装错误解决方法
错误: npm ERR! at Object.parse (native) npm ERR! at Packer.readRules (/usr/local/lib/node_modules/npm/ ...
- JavaWeb限流QPS简易框架
Java Web利用filter实现拦截请求,统计信息.并控制单台机器QPS. /** * 网络流量控制器 */ public class TrafficFilter implements Filte ...
- [汇编语言]-第二章DEBUG
Debug查看CPU各种寄存器中得内容,内存的情况和在机器码级跟踪程序的运行. 1- 进入Debug xp 开始-运行 cmd 输入 debug 2- Debug功能 r 查看,改变CPU寄存器的内容 ...