我有一个显示A
的ViewController MPMoviePlayerViewController
。我想强制视频播放器横向显示,所以我使用它:
在AppDelegate中,supportedInterfaceOrientationsForWindow
if let viewController = self.window!.rootViewController?.presentedViewController {
if let playbackController = viewController as? MPMoviePlayerViewController {
return Int(UIInterfaceOrientationMask.LandscapeLeft.rawValue) | Int(UIInterfaceOrientationMask.LandscapeRight.rawValue)
}
return Int(UIInterfaceOrientationMask.Portrait.rawValue)
}
在我的视频播放器子类中,我设置了支持的方向:
override func supportedInterfaceOrientations() -> Int {
return Int(UIInterfaceOrientationMask.LandscapeLeft.rawValue) | Int(UIInterfaceOrientationMask.LandscapeRight.rawValue)
}
但是,当横向关闭视频播放器时,视图控制器A
会陷入困境。如何阻止View Controller A
切换到横向,并将其保持为纵向?
答案 0 :(得分:0)
Just add
override func supportedInterfaceOrientations() -> Int {
return Int(UIInterfaceOrientationMask.Portrait.rawValue)
}
to every view controller that needs it and avoid AppDelegate based orientation support.