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

  • 相关阅读:
    poj 1080 dp
    Codeforces Round #280 (Div. 2)
    Codeforces Round #279 (Div. 2)f
    Codeforces Round #278 (Div. 1)
    Codeforces Round #276 (Div. 1)
    搜索
    debug 心得
    ZOJ 1633
    DRF 一对多序列化与反序列化
    HTTP协议
  • 原文地址:https://www.cnblogs.com/zhangleixy/p/4974936.html
Copyright © 2011-2022 走看看