正确做法:
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, 所以设置无效