我有一个MPMoviePlayer工作 . 它旨在将邮资大小的电影显示为视图中的子视图 . 当手机旋转为横向时,它将进入全屏模式 . 当手机处于人像状态时,它会进入邮票图像模式 .
唯一的问题是当我在横向模式下按Done时,它会保留在风景中,带有邮票大小的电影,而不是重新开始画像 .
这是我的一些代码:
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
[moviePlayerController setFullscreen:YES animated:YES];
} else
{
[moviePlayerController setFullscreen:NO animated:YES];
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeLeft;
}
按完成后如何让它进入纵向模式?
4 回答
@cannyboy ...如果您的应用程序仅适用于纵向模式,您只需在APPDelegate.m中使用以下方法
我是同样的问题,现在我告诉你我是如何解决它的 . 我不知道下面的方法是对还是错,但它工作正常 .
而不是在视图中打开
MPMoviePlayer
而不是在新的_2580785中打开它 . 我的意思是创建一个新的UIViewController
来显示电影并将它推到一些如何使用户不会理解他们正在重定向到新的屏幕 .禁用横向模式的父屏幕并允许
MovieViewController
进行横向显示 .当用户按下完成按钮或关闭按钮时,
viewController
和之前的屏幕不支持横向模式,因此屏幕将自动以纵向模式显示 .请注意,这仅适用于ios 5.0及更高版本,并且您将收到不支持setOrientation的警告,但它运行良好
您可以尝试的一种方法是强制您的设备认为它处于纵向模式 . 为此,请尝试使用:
如果您不希望您的设备在不播放电影时显示横向,则还必须在上面显示的代码中添加一些逻辑,以便仅在播放电影时更改为横向 .