Mat*_*Mat 4 iphone ios ios6 iphone-5
在之前的iOS版本中,我们的视频会自动旋转,但在iOS 6中则不再如此.我知道presentMoviePlayerViewControllerAnimated之前的设计是为了做到这一点,但我如何告诉MPMoviePlayerViewController自动旋转?
MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:moviePlayer];
Run Code Online (Sandbox Code Playgroud)
Oll*_*rst 10
在appdelegate.m中:
- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if ([[self.window.subviews.lastObject class].description isEqualToString:@"MPMovieView"]) {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else {
return UIInterfaceOrientationMaskPortrait;
}
}
Run Code Online (Sandbox Code Playgroud)
有点黑客,但效果很好......
我刚遇到同样的问题.James Chen的解决方案是正确的,但我最终做了一些更简单的工作 - 覆盖应用程序:supportInterfaceOrientationsForWindow在我的app委托中,如果我的rootView控制器是模态呈现MPMoviePlayerViewController则返回allButUpsideDown.不可否认,这可能并不适合所有情况,但是我不得不更改所有视图控制器:
- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [rootViewController.modalViewController isKindOfClass:MPMoviePlayerViewController.class ] ? UIInterfaceOrientationMaskAll : UIInterfaceOrientationMaskAllButUpsideDown;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8023 次 |
| 最近记录: |