zoukankan      html  css  js  c++  java
  • iOS使用push隐藏子页面底部bottom TabBar

    下面两种情况是我在开发过程中遇到的,一种是代码使用pushViewController,还有一种是storyboard直接使用push。之前也查阅了非常多关于隐藏底部tabbar的资料。可是要么使用起来麻烦,要么就是藕合度高代码不规范(这里有点代码洁癖,当前类相关的事务应该写在本类中)。
    1、使用pushViewController
    如A->B;A是列表页。带有tabbar;B是内容页。不须要tabbar;

    在A的事件中打开B。例如以下代码

    -(void)showVideo:(EJAlbumModel *)model bySId:(NSString *)sid{
    NSLog(@"%@",@"运行托付");
    EJClassVideoViewController *videoController=[[EJClassVideoViewController alloc] init];
    videoController.model=model;
    videoController.semesterClassId=sid;
    self.navigationItem.backBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleBordered target:nil action:nil];// 改动下级页面的返回button,此处我是非常想写到videoController中,可是backBarButtonItem的机制决定必须写在A中;
    [self.navigationController pushViewController:videoController animated:YES];
    }
    在B的载入View视图事件initWithNibName中。增加 self.hidesBottomBarWhenPushed=YES;就可以实现打开B隐藏tabbar。返回A又一次现实tabbar。非常easy吧

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

    2、使用storyboard
    在storyboard中建立A和B,并使用ctrl+链接至B,即segue的打开方式。例如以下图所看到的:



    此处仅仅须要在可视化视图中改动B的一个属性就可以(可惜非常多技术文章都没提到这点,是由于我没有找到吗)。例如以下图,选中B视图。并勾选Hide Bottom Bar on Push;



  • 相关阅读:
    [Windows Server 2012] 安装PHP+MySQL方法
    [Windows Server 2012] 安装IIS8.5及FTP
    [Windows Server 2012] IIS自带FTP配置方法
    护卫神,服务器安全专家!
    ie9 UpdateModel失败
    打包自己的nuget时,设置安装此nuget改写web.config
    Roslyn 1.2.0.0 的改变
    用自定义routes把不同的querystring名对应到action同一个参数上
    JetBrains dotCover 2.0 破解研究(注册机)
    mvc4 中的 AuthorizeAttribute
  • 原文地址:https://www.cnblogs.com/claireyuancy/p/6957643.html
Copyright © 2011-2022 走看看