iphone - 强制 MPMoviePlayerController 横向播放

标签 iphone cocoa-touch ios

我是 iPhone 开发的新手,正在编写我的第一个应用程序。整个App只需要竖屏模式,播放电影除外。我正在使用 MPMoviePlayerController 来启动电影,它以 protrait 模式播放。我如何强制 MPMoviePlayerController 以横向播放所有电影。 我正在使用 Xcode 4 并为 iOS 4.0+ 构建。我是否需要在 info.plist 中输入一些设置以允许 MPMoviePlayerController 横向播放?

这是我用来初始化 MPMoviePlayerController 的代码:

MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL: url]; 
[self.view addSubview:theMovie.view];
theMovie.allowsAirPlay=YES;
[theMovie setFullscreen:YES animated:YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
[theMovie play]; 

最佳答案

将播放器嵌入到它自己的 View Controller 中并实现 shouldAutorotateToInterfaceOrientation 如下:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

关于iphone - 强制 MPMoviePlayerController 横向播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5791703/

相关文章:

ios - 如何在 iOS 中检查没有为 Touch ID 添加指纹

ios - writeToFile 和 writeToURL 有什么区别?

iphone - UIView 基于 block 的动画的重复计数

ios - 无法在 Kiwi 中的模拟 CLLocation 对象上 stub 时间戳

ios - CLLocationManager 忽略 stopUpdatingLocation

iphone - 页面控制宽度问题

iphone - 如何在没有服务器的情况下使用iPhone自动续订

ios - 是否可以调整 UIButton 的 titleLabel 的 x,y 位置?

cocoa-touch - UIWebView KVO是否兼容?

ios - 通过 AirDrop (iOS) 发送文件,收件人没有机会接受/拒绝文件