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;



  • 相关阅读:
    Mac OSX下增加TCP连接数
    Connection reset by peer的常见原因及解决办法
    修改主机名
    docker 查看 docker容器启动 完整命令
    nginx 日志打印响应时间 request_time 和 upstream_response_time
    Ubuntu16.04 安装 Docker
    VictoriaMetrics vmagent 使用
    VictoriaMetrics vmauth 使用
    VictoriaMetrics集群模式的一些说明
    promgen prometheus 配置文件生成工具
  • 原文地址:https://www.cnblogs.com/claireyuancy/p/6957643.html
Copyright © 2011-2022 走看看