gpt4 book ai didi

ios - 将横向的 MPmovieViewController 解除为仅纵向 View 时出错(UIApplicationInvalidInterfaceOrientation)

转载 作者:行者123 更新时间:2023-11-28 20:00:23 25 4
gpt4 key购买 nike

我正在为 IOS7 创建一个 xcode 应用程序,它在大多数 View 中以纵向模式工作。

项目设置允许“Portrait”“Landscape Left”和“Landscape Right”。

在我只想以纵向显示的 View 中,我添加以下代码以将它们锁定为纵向模式:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(BOOL)shouldAutorotate
{
return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}

在其中一个锁定 View 中,我使用以下代码呈现了一个 MPmovieViewController:

MPMoviePlayerViewController *movieViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:replayURL];
movieViewController.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

[self presentMoviePlayerViewControllerAnimated:movieViewController];

此代码创建了一个我可以在纵向和横向中使用的 MPmovieViewController。 (这就是我想要的)

当我在横向模式下按下 MPMovieViewController 的完成按钮以关闭 MovieController 时出现问题。之前的 View 不支持横向模式,所以出现以下错误:

 *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'

我如何在关闭 MPMovieViewController 时强制旋转回到纵向模式?

最好的问候

理查德

最佳答案

我在回答我自己。其实很简单。

只需添加到仅纵向 View :

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; }

谢谢

关于ios - 将横向的 MPmovieViewController 解除为仅纵向 View 时出错(UIApplicationInvalidInterfaceOrientation),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24436008/

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