问题
I'm developing an app that first presents a UICollectionView with a bunch of buttons that modally open a subclass of AVPlayerViewController with a custom "Over Full Screen" segue. UIViewControllerBasedStatusBarAppearance is set to YES in my Info.plist.
Here's a small (had to zoom out, sorry) screenshot of all the view controllers in Interface Builder:
The segue was defined in IB. When the user taps a collection view cell, I use performSegueWithIdentifier() to, well, perform the segue.
The problem I'm now experiencing is this:
Why does the status bar hide along with the playback controls in landscape mode, while doing the exact opposite in portrait mode?
Making prefersStatusBarHidden() return true in my subclass of AVPlayerViewController doesn't do anything. What gives?
回答1:
Just figured out a solution:
extension UINavigationController {
public override func childViewControllerForStatusBarHidden() -> UIViewController? {
return self.childViewControllers.last
}
public override func childViewControllerForStatusBarStyle() -> UIViewController? {
return self.childViewControllers.last
}
}
Yup, just override those two functions for all Navigation View Controllers in your app. I consider this to be a hack and not the 'correct' solution to this problem, so use this with caution.
As far as I can tell, this should never fail. In my app, every Navigation VC has exactly one child VC, but YMMV.
来源:https://stackoverflow.com/questions/33871020/cant-hide-status-bar-in-avplayerviewcontrollers-portrait-mode