一、创建一个 Tabbed Application.默认创建的是带有两个Tab的工程。

二、在AppDelegate.h里面添加

  1. @property (strong, nonatomic) UINavigationController *NaviView1Controller;
  2. @property (strong, nonatomic) UINavigationController *NaviView2Controller;

三、修改AppDelegate.m文件的didFinishLaunchingWithOptions函数,在这里我们设置相应的UINavigationController.

  1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  2. {
  3. self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
  4. // Override point for customization after application launch.
  5. UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
  6. UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];
  7. self.tabBarController = [[[UITabBarController alloc] init] autorelease];
  8. self.tabBarController.viewControllers = @[viewController1, viewController2];
  9. self.window.rootViewController = self.tabBarController;
  10. [self.window makeKeyAndVisible];
  11. return YES;
  12. }

修改后:

  1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  2. {
  3. self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
  4. // Override point for customization after application launch.
  5. UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
  6. viewController1.title = @"View1";
  7. self.NaviView1Controller = [[[UINavigationController alloc] initWithRootViewController:viewController1] autorelease];
  8. UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];
  9. viewController2.title = @"View2";
  10. self.NaviView2Controller = [[[UINavigationController alloc] initWithRootViewController:viewController2] autorelease];
  11. self.tabBarController = [[[UITabBarController alloc] init] autorelease];
  12. self.tabBarController.viewControllers = @[self.NaviView1Controller, self.NaviView2Controller];
  13. self.window.rootViewController = self.tabBarController;
  14. [self.window makeKeyAndVisible];
  15. return YES;
  16. }
    1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    2. {
    3. self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    4. // Override point for customization after application launch.
    5. UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
    6. viewController1.title = @"View1";
    7. self.NaviView1Controller = [[[UINavigationController alloc] initWithRootViewController:viewController1] autorelease];
    8. UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];
    9. viewController2.title = @"View2";
    10. self.NaviView2Controller = [[[UINavigationController alloc] initWithRootViewController:viewController2] autorelease];
    11. self.tabBarController = [[[UITabBarController alloc] init] autorelease];
    12. self.tabBarController.viewControllers = @[self.NaviView1Controller, self.NaviView2Controller];
    13. self.window.rootViewController = self.tabBarController;
    14. [self.window makeKeyAndVisible];
    15. return YES;
    16. }

UINavigationController和UITabBarController合用的更多相关文章

  1. iOS开发——实战OC篇&环境搭建之Xib(玩转UINavigationController与UITabBarController)

    iOS开发——实战OC篇&环境搭建之Xib(玩转UINavigationController与UITabBarController)   前面我们介绍了StoryBoard这个新技术,和纯技术 ...

  2. iOS开发——实战OC篇&环境搭建之纯代码(玩转UINavigationController与UITabBarController)

    iOS开发——实战OC篇&环境搭建之纯代码(玩转UINavigationController与UITabBarController)   这里我们就直接上实例: 一:新建一个项目singleV ...

  3. iOS开发——实战OC篇&环境搭建之StoryBoard(玩转UINavigationController与UITabBarController)

      环境搭建之StoryBoard(玩转UINavigationController与UITabBarController)   研究了这么就IOS开发,都没有所处一个像样或者自己忙一点的项目.最近自 ...

  4. UIViewController、UINavigationController与UITabBarController的整合使用

    UINavigationController与UITabBarController是iOS开发中最常用的两种视图控制器,它们都属于UIViewController的子类,继承关系如下: @interf ...

  5. UINavigationController与UITabBarController相关问题

    UINavigationController与UITabBarController相关问题 UINavigationController与UITabBarController混用是非常常见的,有时候会 ...

  6. UINavigationController和UITabBarController

    UINavigationController和UITabBarController 目录 概述 UINavigationController UITabBarController 实用功能 待解决 概 ...

  7. UINavigationController与UITabbarController的样式

    之前虽然也手写过这两中视图控制器,但是更多的还是使用SB来创建,最近发现了一些问题,现在总结一下. 1.改变UINavigationBar的颜色 在UINavigationController中,之前 ...

  8. UINavigationController 与 UITabBarController

    http://www.cnblogs.com/YouXianMing/p/3756904.html // index start from 1. UITabBarItem *newsItem = [[ ...

  9. UINavigationController  和 UITabBarController

    UINavigationController当设置根控制器的时候,意思就是把根控制器压入栈内,当我们push的时候,我们把下一个控制器压入栈内,当我们pop的时候把上面的控制器的内存释放   UITa ...

随机推荐

  1. javascript 判断系统设备

    <script> function detectOS() { var sUserAgent = navigator.userAgent; var isWin = (navigator.pl ...

  2. sqlplus常用操作命令2

    常用编辑命令:A[ppend] text 将text附加到当前行之后C[hange] /old /new 将当前行中的old替换为newCLear] buff[er] 清除缓冲区中的所有行DEL 删除 ...

  3. NET基础课--NET中程序集0-1

    程序集 1.表现形式:.dll  和. exe . 2.程序集组成:PE头,CLR头,清单,元数据,CIL代码,资源文件.实际上这些内容包含在一个叫做Module的逻辑结构中. 单模块程序集:程序集就 ...

  4. xmanager 在 Windows 下远程桌面连接 麒麟

    编辑/etc/gdm/custom.conf,添加如下内容: [daemon] RemoteGreeter=/usr/libexec/gdmgreeter  注:“远程登录界面与本地登录界面相同”功能 ...

  5. HTML5 自定义属性 data-*介绍

    在HTML5之前HTML4我们也可以自定义属性通过setAttribute去设置或者直接写在HTML标签里面那么HTML5新增data-*(*可以替换成你喜欢的任意名字)属性有什么用呢? 更便的捷操作 ...

  6. MySql5压缩包安装

    一. 解压所有文件到一个目录:例如D:\Program Files\mysql-5.6.22-winx64 二. 配置系统的环境变量:在Path路径后追加:;D:\Program Files\mysq ...

  7. 关于mysql的安装

    上个学期学了数据库后,曾多次试图安装数据库,但由于电脑的种种的原因或者是安装的问题,始终没能安装成功,今天终于succeed. 一.下载 首先从www.mysql.com网站上下载mysql,我下载的 ...

  8. oracle add_months函数的用法详解

    如果需要取上一个月的数据,并且每天都要进行此操作,每次都需要改时间,的确非常的麻烦,所以想到了oracle add_months函数这个函数 oracle add_months函数: oracle a ...

  9. Python之路第十一天,高级(3)-Python操作 Memcached、Redis

    Memcached Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度 ...

  10. Hbase深入学习(一) 什么是hbase

    Hbase深入学习(一) 什么是hbase 一.hbase是什么?      首先hbase是一个在Hadoop的HDFS分布式存储系统上介于映射(key/value)的nosql的分布式数据库:它通 ...