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

  • 相关阅读:
    array_unique() 去重复
    datagrid导出数据
    $this->success传递数据
    二分+暴力状压+桶——cf1288D
    乱搞+虚假莫队?+树状数组——cf1288E
    字符串+置换+莫队离线处理——cf1290B
    扩展域并查集+图论——cf1290C 好题
    换根dp+暴力+预处理+记忆化搜索——cf1292C好题!
    线段树,思维——cf1295E
    暴力,贪心——cf1292B
  • 原文地址:https://www.cnblogs.com/zhangleixy/p/4974936.html
Copyright © 2011-2022 走看看