gpt4 book ai didi

ios - 如何在仅纵向应用程序中使用 MPMovieViewController 播放横向视频

转载 作者:可可西里 更新时间:2023-11-01 03:40:07 24 4
gpt4 key购买 nike

我的应用程序支持的界面方向是纵向和颠倒。但是,当播放视频时,我希望它能全屏横向播放。目前使用此代码,即使设备旋转,它也只能播放纵向:

[player.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
player.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self presentMoviePlayerViewControllerAnimated:player];

我怎样才能强制它进入横向模式?

最佳答案

这是我的做法:
在项目文件中,确保您支持景观方向 supported interface orientations
现在,在所有仍应为 Portrait Only 的 ViewController 中,添加此代码

//ios6
- (BOOL)shouldAutorotate {
return NO;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

//ios4 and ios5
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

我已经加入了 iOS5 和 iOS6 调用,这样我的代码就可以在两者上运行。

当您的 MPMoviePlayerController View 变为全屏时,它将是一个新的 ViewController,位于其他所有 View 之上。因此,它可以根据项目支持的界面方向进行旋转。它不会看到您在哪里强制其他 ViewControllers 进入纵向。

关于ios - 如何在仅纵向应用程序中使用 MPMovieViewController 播放横向视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13021520/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com