我想问及回答我自己的问题,万一其他人会发现它有用。
使用
,moviePlayer将按照预期开始播放moviePlayer.view.frame = self.view.bounds
但是,在电影中期旋转时,tabBar会旋转,但不会旋转moviePlayer。这将裁剪电影屏幕的一部分,或者它不会像原先预期的那样改变以填满整个屏幕。
答案 0 :(得分:4)
在func viewDidLoad()中添加此通知服务:
NSNotificationCenter.defaultCenter() .addObserver(self, selector: "movieOrientationChanged", name: UIDeviceOrientationDidChangeNotification, object: nil)
和,这里的方法(moviePlayer是MPMoviePlayerController类型的类变量)响应该通知:
func movieOrientationChanged() {
moviePlayer!.view.frame = self.view.bounds
}
答案 1 :(得分:1)
for swift 4在viewDidLoad
中添加此代码NotificationCenter.default .addObserver(self, selector: #selector(VideoViewViewController.movieOrientationChanged), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)