iphone - 在电影播放器​​上按“完成”后恢复纵向?

标签 iphone objective-c ios mpmovieplayercontroller

我有一个正在运行的 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/

相关文章:

ios - 通过 Objective-C 代码解析 XML

objective-c - 阻止 UIToolbar 在横向方向上消失 - iPad

ios - 多个应用具有相同的 IAP 产品 ID

ios - 使用未声明的类型 'XCTestCaseEntry'

iphone - 实现 AdWhirl + iAD

iphone - 重写 iOS 应用程序以在 iOS 和 Mac 上运行 - 如何组织 Controller 代码?

ios - 在 UITableView 中显示一个表中的中型数据集

iphone - 在ios中解析嵌套对象和数组json

ios - 从我的联系人中执行调用

android - Flex 移动警报 - 本地通知