• iOS:hidesBottomBarWhenPushed的正确用法


    iOS:hidesBottomBarWhenPushed的正确用法

    Case1xib加载或者Storyboardidentifier获取Controller

    UIViewController *v2 = [self.storyboard instantiateViewControllerWithIdentifier:@"v2"];

    v2.hidesBottomBarWhenPushed = YES;

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

    Case2:拉线,也就是StoryboardperformSegue

    self.hidesBottomBarWhenPushed = YES;

    [self performSegueWithIdentifier:@"tov2" sender:nil];

    self.hidesBottomBarWhenPushed = NO;

    Tip:经测试证明,此种方式只会对后面的一级生效,继续往后Push还会出现TabBar,要继续往后push也隐藏Tabbar还得使用Case3的方法,也建议如此!

    Case3:拉线,在prepareForSegue函数里

    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

    {

        [segue.destinationViewController setHidesBottomBarWhenPushed:YES];

    }

    更方便的做法:如果用 Storyboard,可以在 ViewController 的设置面板中把 Hide Bottom Bar on Push 属性勾选上,效果和上文代码一样。

    暂时就用到这几点,我之前的做法,自己手动隐藏,拉伸view,显示不但麻烦,兼容性也不好,移到iOS7上问题多多,不过用这个属性可以非常方便的实现此需求,并且在iOS6上也完美兼容哦。

    注意:还有个问题,这个属性只支持非自定义的Tabbar,也就是只支持原生Tabbar,如果是自定义的Tabbar会产生你意想不到的效果,我之前就遇到过,因为使用hidesBottomBarWhenPushed后,系统内部会处理TabbarControllerTabbar这个View,我之前自定义的Tabbar做法是吧原生Tabbar这个View隐藏掉,然后添加到自己绘制的Tabbar
    View上去,缺点就是这样你的自定义的TabBarview接收不到系统应有的一些响应,于是我尝试着把自定义的TabBar
    View添加到原来的TabBar View上,也就是不隐藏原生的TabBar,而是覆盖在上面,看不出任何区别,效果也能达到上面图片的效果!

  • 相关阅读:
    Java语法基础
    配置环境变量
    常用Dos命令
    Python 之 进程与进程池的创建和使用
    python之进程间通信
    低级别网络接口-socket的应用和粘包现象
    网络编程之模块的使用
    Python异常类型
    练习题
    python 的re模块与正则表达式
  • 原文地址:https://www.cnblogs.com/Xunqf/p/4238911.html
Copyright © 2020-2023  润新知