一、创建一个 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. C# DES 加密解密

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.S ...

  2. C#关于ref的用法(多个实参值的传递)

    按照C#默认的按值调用参数的传递机制,不能刻编写出一个方法来实现两个int类型的值交换,因为一个方法只能对应一个返回值,如何实现将两个交换的值传递回去,这里我将用到的是ref修饰符. 使用ref的单值 ...

  3. MVC 过滤器 ActionFilterAttribute

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  4. [转]如何正确清理C盘

    转自微软的Answers网站. 以下是推荐使用的方法,安全且不会误删有用的系统文件 1.尽量不要在C盘安装应用软件,在软件安装时,一般可以手动指定安装路径,您可以将软件指定安装到其他盘符. 在使用它们 ...

  5. JSP EL表达式详细介绍(转)

    转自:http://www.jb51.net/article/20042.htm 为了使JSP写起来更加简单. 表达式语言的灵感来自于 ECMAScript 和 XPath 表达式语言,它提供了在 J ...

  6. php中Maximum execution time of 120 seconds exceeded时间超时错误解决方案

    1.修改php的配置文件,找到php.ini文件 max_execution_time = 120 ;//设置成你想要的值,单位是秒 2.使用ini_set()函数,使用这个函数来改变你的最大执行时间 ...

  7. CS0016: 未能写入输出文件*****目录名称无效

    一大早,杀毒软件弹出删除隐私记录.清理空间一堆堆的提醒,一般我都是无视它,今天顺便点了下清理,然后出问题. 昨晚下班提交的代码,程序运行好好地,今早清理完系统,竟然就出问题了, 具体如下 CS0016 ...

  8. 关于ajax发送的数据问题

    今天在做保存富文本编辑器的内容时,发送了一个ajax请求: $.ajax({ type:"POST", url:"{% url 'cms:add' %}", d ...

  9. python实现简单表单校验框架

    # encoding=utf-8 from app.models import Student from flask import g import re from flask.ext.wtf imp ...

  10. SemaphoreFullException when checking user role via ASP.NET membership

    将指定的计数添加到该信号量中会导致其超过最大计数 This issue was fixed by restarting ASP.NET Development Server on windows ta ...