在以前的 iOS 版本中,我们的视频会自动旋转,但在 iOS 6 中不再如此。我知道 presentMoviePlayerViewControllerAnimated 以前是设计用来做这个的,但是我怎么能告诉 MPMoviePlayerViewController 自动旋转呢?
MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:moviePlayer];
最佳答案
在 appdelegate.m 中:
- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if ([[self.window.subviews.lastObject class].description isEqualToString:@"MPMovieView"]) {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else {
return UIInterfaceOrientationMaskPortrait;
}
}
有点黑客,但效果很好......
关于iOS 6 MPMoviePlayerViewController 和presentMoviePlayerViewControllerAnimated Rotation,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12593542/