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 ...
随机推荐
- linux上大量tcp端口处于TIME_WAIT的问题
今天发现网站突然无法访问,登陆webserver已经无法连接mysql,转战mysql一看,发现竟然有三千多个TIME_WAIT连接,擦,被SYN攻击了?百度&&google,发现通过 ...
- OSError: [Errno 13] Permission denied: '/etc/cron.d/1sandbox_registration'
使用Hortonworks 的twitter tutorial: http://hortonworks.com/hadoop-tutorial/how-to-refine-and-visualize- ...
- Asp.net MVC5中Html.DropDownList的使用
一.静态下拉列表项的绑定 在下拉列表中绑定静态项,我们可以通过 SelectListItem 的集合作为数据源的下拉列表. @Html.DropDownList("dropRoles&quo ...
- css基础之 图片瀑布流布局:用CSS+DIV等宽格子堆砌瀑布流效果 (一)
<!doctype html> <html> <head> <meta charset="UTF-8"/> <title> ...
- API 之 MessageBox
函数功能: MessageBox 函数用于显示一个模态对话框,其中包含一个系统图标. 一组按钮和一个简短的特定于应用程序消息,如状态或错误的信息.消息框中返回一个整数值,该值指示用户单击了哪个按钮. ...
- apache 设置
此博客是网站www.beilei123.cn镜像,转载请注明出处. 1.ServerTokens ProdServerTokens Prod 显示“Server: Apache”ServerToken ...
- js scroll 教程
<html><head><script language=javascript>function s(){var c = window.document.body. ...
- CentOS minimal版安装图形界面的步骤(自动获取IP)
1.连接网络: CentOS minimal.iso安装好后,进入终端,默认是不开网络的, 首先启用网卡, 自动获取ip. ifconfig eth0 up www.2cto.com dhcli ...
- Print! Print! Print!
print语句可以实现打印--只是对程序员友好的标准输出流的接口而已. 从技术角度来讲,这是把一个或多个对象转换为其文本表达形式,然后发送给标准输出或另一个类似文件的流. 更详细地说,在Python中 ...
- 1003 Crashing Balloon
考察DFS的应用,判断两个数的因子. #include <stdio.h> int f1,f2; void DFS(int m,int n,int k){ ){ f2=; ) f1=; } ...