0
視圖控制器被推動和底部標籤欄被隱藏,像這樣:爲什麼hidesBottomBarWhenPed不工作時沒有根視圖控制器?
let myViewController = self.storyboard?.instantiateViewController(withIdentifier: MyViewController) as! MyViewController
myViewController.hidesBottomBarWhenPushed = true
navigationController?.pushViewController(myViewController, animated: true)
即正常工作。
但是,當我更改根視圖控制器之前推底部欄不隱藏。
// Change the root view controller
let firstRootViewController = UIApplication.shared.keyWindow!.rootViewController
UIApplication.shared.keyWindow!.rootViewController = secondRootViewController
// Push view on stack of navigation controller which is a child of firstRootViewController
let myViewController = self.storyboard?.instantiateViewController(withIdentifier: MyViewController) as! MyViewController
myViewController.hidesBottomBarWhenPushed = true
navigationController?.pushViewController(myViewController, animated: true)
// Some more things happen...
// Switch back to previous root view controller
UIApplication.shared.keyWindow!.rootViewController = firstRootViewController
其結果是,導航控制器正確地推myViewController
但底部欄可見,彷彿參數hidesBottomBarWhenPushed
被忽略。
這裏有什麼問題?