在以前的 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;
}
}
有点黑客,但效果很好......
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)