Ответ 1
Да. Вы можете принудительно изменить ориентацию, когда MPMoviePlayercontroller переходит в полноэкранный режим. Просто добавьте уведомление MPMoviePlayerWillEnterFullscreenNotification observer в свой viewdidload/viewwillappear и измените ориентацию следующим образом
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "videoMPMoviePlayerWillEnterFullscreen:", name: MPMoviePlayerWillEnterFullscreenNotification, object: nil);
//change orientation to portrait when user exits the full screen
NSNotificationCenter.defaultCenter().addObserver(self, selector: "videoMPMoviePlayerWillExitFullscreenNotification:", name: MPMoviePlayerWillExitFullscreenNotification, object: nil);
}
func videoMPMoviePlayerWillEnterFullscreen(notification:NSNotification)
{
let value = UIInterfaceOrientation.LandscapeLeft.rawValue ;// UIInterfaceOrientation.LandscapeRight.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}
func videoMPMoviePlayerWillExitFullscreenNotification(notification:NSNotification)
{
let value = UIInterfaceOrientation.Portrait.rawValue ;// UIInterfaceOrientation.LandscapeRight.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}
не забудьте удалить наблюдателя.
Делегат приложения может реализовать приложение: supportedInterfaceOrientationsForWindow: вернуть UIInterfaceOrientationMask, который используется вместо значений из приложения Info.plist.
class AppDelegate: UIResponder, UIApplicationDelegate {
.....
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.AllButUpsideDown;//UIInterfaceOrientationMask.All for iPad devices
}
}
Ссылка: - https://developer.apple.com/library/ios/qa/qa1688/_index.html