一、创建一个 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# 枚举运用"位"操作和"或"操作

    定义: /// <summary> /// The js function type(the same as name). /// </summary> [Flags] pub ...

  2. 读取本地文件理解FileReader对象的方法和事件以及上传按钮的美化。

    一.FileReader对象 用来把文件读入内存,并且读取文件中的数据.FileReader对象提供了异步API,使用该API可以在浏览器主线程中异步访问文件系统,读取文件中的数据. 浏览器支持情况, ...

  3. AspnetPager放在UpdatePanel中,回到顶部。

    最近在做一个项目时,使用了AspNetPager分页控件进行分页,为了防止点击下一页时搜索条件消失掉,使用了UpdatePanel来进行局部刷新. 由此引发了一个问题,即点击某一页时,页面没有返回到顶 ...

  4. 【.NetRemoting-3】2015.09.18

    [Remoting程序的基本实现] [一]服务程序集 [1]服务对象必须要求继承[MBR,MarshalByRefObject] [二]服务端应用程序 [1]注册通道 [两种类型的通道] [A]发送请 ...

  5. 深入理解JavaWeb技术内幕(一)

    最近在看许令波的<深入理解JavaWeb技术内幕>.整理了一些笔记.想做一个系列,这篇是系列的第一篇,讲Web请求. B/S架构 最常见的架构方式. 优点: 1.客户端使用统一(此处的统一 ...

  6. 自动化高效css开发,畅谈less的灵活变化

    css是一种让html与样式分离解析而出现的代码,它的出现大大提高了程序员的工作效率,和后期进行维护的效率.但是发展至今,由于起死板单调的写法,越来越不能满足程序员们灵活的思维,很多时候是种恨铁不成钢 ...

  7. Mac ssh登陆linux并且显示linux图形

    背景: Mac 通过[终端]ssh登陆linux并且在Mac显示linux图形 Mac 主机IP: 10.2.1.1 linux 主机IP: 192.168.1.1 说明: 想要ssh访问并且显示li ...

  8. YUM更换源--yum找不到安装包(转)

    公司提供的CentOS VM中,/etc/yum.repos.d 下 只有一个build.repo,其中提供的yum 源只有公司内部的几个源,很多包在这些源中都找不到.于是要添加别的源,下面的帖子中介 ...

  9. 保存mysql用户的登录信息到~.my.cnf文件;用于方便登录操作。

    原理说明: 在用户调用mysql 这个客户端程序去登录目标服务器时,mysql客户端程序会从本地读取配置文件信息,它要去读的配置文件包括 /etc/my.cnf /etc/mysql/my.cnf ~ ...

  10. SQL Server 解决CPU 高占用的一般step

    第一步: 看这些CPU是不是SQL Server用的. 第二步: 确定SQL Server 有没有引发17883\17884错误 第三步: 找出使用CPU最高的语句进行优化.(sys.dm_exec_ ...