您的位置:首页 > 移动开发 > IOS开发

[iOS]用hidesBottomBarWhenPushed属性实现隐藏BottomBar时候的的几个坑!

2015-11-02 16:11 585 查看

正确做法:

1\最简单的是在storyboard的里面

hidesBottomBarWhenPushed设置为YES就可以了

2\如果是代码创建的则: 

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {

        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)

        initialize()

    }

    override init(style: UITableViewStyle) {

        super.init(style: style)

        initialize()

    }

    required init?(coder aDecoder: NSCoder) {

        super.init(coder: aDecoder)

        initialize()

    }

private func initialize() {

        

        tableView.dataSource = self

        tableView.delegate = self

        hidesBottomBarWhenPushed = true

        setInit()

    }

或者在创建好后,马上调用 vc.hidesBottomBarWhenPushed = true

下面有几个新手常掉进去的坑:

1\不能够在viewDidLoad() 方法里调用, 一定要在viewDidLoad加载之前  也就是 push之前调用:

2\区分下面两个方法

hidesBottomBarWhenPushed = true

self.navigationController?.hidesBottomBarWhenPushed = true  这个方法会因为没有被push前,就没有navigationController, 所以设置无效

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  xcode Swift