zoukankan      html  css  js  c++  java
  • UINavigationController和UITabBarController合用

    一、创建一个 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.   
    9.     UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];  
    10.     viewController2.title = @"View2";  
    11.     self.NaviView2Controller = [[[UINavigationController alloc] initWithRootViewController:viewController2] autorelease];  
    12.   
    13.     self.tabBarController = [[[UITabBarController alloc] init] autorelease];  
    14.       
    15.     self.tabBarController.viewControllers = @[self.NaviView1Controller, self.NaviView2Controller];  
    16.       
    17.     self.window.rootViewController = self.tabBarController;  
    18.     [self.window makeKeyAndVisible];  
    19.     return YES;  
    20. }  
    ------------------------
      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.   
      9.     UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];  
      10.     viewController2.title = @"View2";  
      11.     self.NaviView2Controller = [[[UINavigationController alloc] initWithRootViewController:viewController2] autorelease];  
      12.   
      13.     self.tabBarController = [[[UITabBarController alloc] init] autorelease];  
      14.       
      15.     self.tabBarController.viewControllers = @[self.NaviView1Controller, self.NaviView2Controller];  
      16.       
      17.     self.window.rootViewController = self.tabBarController;  
      18.     [self.window makeKeyAndVisible];  
      19.     return YES;  
      20. }  
  • 相关阅读:
    一起谈.NET技术,SharePoint开发笔记SharePoint2010添加ASP.NET应用程序 狼人:
    一起谈.NET技术,系统架构技能之设计模式—代理模式 狼人:
    一起谈.NET技术,.NET中的异步编程(一)为什么需要异步 狼人:
    一起谈.NET技术,Microsoft NLayerApp案例理论与实践 项目简介与环境搭建 狼人:
    一起谈.NET技术,构建高性能ASP.NET站点之减少不必要的请求 狼人:
    一起谈.NET技术,分享在MVC3.0中使用jQuery DataTable 插件 狼人:
    一起谈.NET技术,ASP.NET 4的Demo实践:URL路由改进支持 狼人:
    一起谈.NET技术,构建高性能ASP.NET站点之优化HTTP请求 狼人:
    一起谈.NET技术,Silverlight 游戏开发小技巧:传说中的透视跑马灯 狼人:
    paip.Winista HTMLParser文本结点的获取
  • 原文地址:https://www.cnblogs.com/flyingdreaming/p/3266047.html
Copyright © 2011-2022 走看看