我想在我的仅肖像应用程序中使用MPMoviePlayerViewController播放电影 . 所以,我喜欢这个 .
- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if ([[window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]]) {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else {
return UIInterfaceOrientationMaskPortrait;
}
}
结果,我可以在横向模式下玩 . 但是,当我忽略我的应用程序处于横向模式时 . 那么,有没有办法在 supportedInterfaceOrientationsForWindow 中动态地将我的应用程序更改为纵向模式 . 我知道我可以在MPMoviePlayerViewController退出时收到通知 . 但我不知道如何在退出时将我的应用程序设置回纵向 .
1 回答
1)设置设备方向:仅限纵向模式 .
2)之后,转到ViewController.m类(要显示MPMoviePlayerViewController),并添加以下通知: