iOS 6 MPMoviePlayerViewController和presentMoviePlayerViewControllerAnimated Rotation [英] iOS 6 MPMoviePlayerViewController and presentMoviePlayerViewControllerAnimated Rotation

查看:114
本文介绍了iOS 6 MPMoviePlayerViewController和presentMoviePlayerViewControllerAnimated Rotation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在之前的iOS版本中,我们的视频会自动旋转,但在iOS 6中则不再如此。我知道presentMoviePlayerViewControllerAnimated之前是为了这么做而设计的,但我如何告诉MPMoviePlayerViewController自动旋转?

In previous iOS versions, our video would rotate automatically but in iOS 6 this is no longer the case. I know that the presentMoviePlayerViewControllerAnimated was designed to do that before but how can I tell the MPMoviePlayerViewController to rotate automatically?

MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:moviePlayer];


推荐答案

在appdelegate.m中:

In appdelegate.m :

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    if ([[self.window.subviews.lastObject class].description isEqualToString:@"MPMovieView"]) {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }
    else {
        return UIInterfaceOrientationMaskPortrait;
    }
}

有点黑客,但效果很好......

Kinda a hack, but works well...

这篇关于iOS 6 MPMoviePlayerViewController和presentMoviePlayerViewControllerAnimated Rotation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆