ios - 横向/所有方向的 MPMoviePlayerViewController

标签 ios objective-c mpmovieplayercontroller screen-orientation

我的问题真的很简单,教程和答案都没有解决我的问题。

我有一个带有设置的应用程序:

enter image description here

我想在我的所有 viewController 中仅支持纵向/颠倒方向,除非我想通过以下方式播放视频:

MPMoviePlayerViewController

代码如下:

MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[Videos videoURL:video.hash]];
if (mp) {
    isVideoPlaying = YES;

    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(videoFinishedPlaying:)
     name:MPMoviePlayerPlaybackDidFinishNotification
     object:mp.moviePlayer];

    [self presentMoviePlayerViewControllerAnimated:mp];
    mp.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
    [mp.moviePlayer play];
    [mp release];
}

MPMoviePlayerViewController 播放视频时,我希望支持所有方向。
需要你的帮助。

最佳答案

您应该允许按以下方式轮换:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     // Return YES for supported orientations
}

iOS 6:

- (NSUInteger)supportedInterfaceOrientations
{

    return UIInterfaceOrientationMaskAll;
}

将代码放在调用播放器的.m文件中

关于ios - 横向/所有方向的 MPMoviePlayerViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14518894/

相关文章:

ios - 如何以 headless 模式或无窗口启动模拟器

ios - iBeacon uuid 是否与 MACID 相同

ios - 如何在 iOS 9 上从特定点开始播放视频

ios - MPMoviePlayerController 再次向后缓冲视频

iphone - 在后台使用MPMoviePlayer播放mp3文件

ios - 为什么我的分布式应用程序看起来与在 xcode 中调试时不同?

ios - Apple单例代码警告......再次

iphone - UITableView scrollIndicator 位置不正确

ios - 在 iOS 中使用 NSDictionary 的可扩展 UITableview 单元格

ios - RestKit 并作为 NSManagedObject 保存到 CoreData