我有一个正在运行的 MPMoviePlayer。它旨在将邮票大小的电影显示为 View 中的 subview 。当手机旋转成横向时,它会进入全屏模式。当手机处于纵向时,它会进入邮票纵向模式。
唯一的问题是,当我在横向模式下按“完成”时,它仍然是横向的,带有邮票大小的电影,而不是回到纵向。
这是我的一些代码:
-(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;
}
我如何让它在按下“完成”后进入纵向模式?
最佳答案
@cannyboy...如果您的应用程序仅适用于纵向模式,您只需在 APPDelegate.m 中使用以下方法
- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
if ([[window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]])
{
//NSLog(@"in if part");
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else
{
//NSLog(@"in else part");
return UIInterfaceOrientationMaskPortrait;
}}
关于iphone - 在电影播放器上按“完成”后恢复纵向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7407567/