zoukankan      html  css  js  c++  java
  • IOS UITabBarViewController 和UINavigationController 结合使用

    在AppDelegate.m  didFinishLaunchingWithOptions

    UITabBarViewController *tabView=[[UITabBarViewController alloc] init];

    //Tab 1
    ViewController1 *VC1=[[ViewController1 alloc] init];
    VC1.title=@"VC1";
    UINavigationController *nav2=[[UINavigationController alloc]initWithRootViewController:VC1];

    //Tab 2
    ViewController2 *VC2=[[ViewController2 alloc] init];
    VC2.title=@"VC2";
    UINavigationController *nav2=[[UINavigationController alloc]initWithRootViewController:VC2];

    //Tab 3
    ViewController3 *VC3=[[ViewController3 alloc] init];
    VC3.title=@"VC3";
    UINavigationController *nav3=[[UINavigationController alloc]initWithRootViewController:VC3];

    [tabView setViewControllers:[NSArray arrayWithObjects:nav1,nav2,nav3,nil]];

    self.window.rootViewController=tabView;
    [self.window makeKeyAndVisible];

    VC1中隐藏NavigationBar,然后显示ToolBar

    [self.navigationController setNavigationBarHidden:YES animated:YES];

    VC1 跳转到VC4

    ViewController4 *VC4=[[ViewController4 alloc] init];
    [self.navigationController pushViewController:VC4 animated:YES];

    VC1 跳转到VC4  并且隐藏TabBar

    方法1:

    ViewController4 *VC4=[[ViewController4 alloc] init];

    [VC4 setHidesBottomBarWhenPushed:YES];

    [self.navigationController pushViewController:VC4 animated:YES];

    方法2:

    在VC4  m文件里面

    -(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
       self.hidesBottomBarWhenPushed = YES;
    }
    return self;
    }

    关于initWithNibName 请参考

    http://www.cnblogs.com/geraldzhang/archive/2011/09/21/2183970.html

  • 相关阅读:
    LoadRunner使用记录
    JVM&GC详解
    常用网络操作命令
    IP地址、子网掩码、网络号、主机号、网络地址、主机地址详解
    交换机配置记录
    持续集成与自动化部署---代码流水线管理及Jenkins和gitlab集成
    Git的安装与使用详解
    性能测试---问题记录
    性能测试---实战篇
    c++实用快捷键
  • 原文地址:https://www.cnblogs.com/zhangleixy/p/4974936.html
Copyright © 2011-2022 走看看