我是 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/