首页 文章

MPMoviePlayerController可以全屏旋转,而应用程序仅支持ios 7中的纵向方向

提问于
浏览
0

我在这里遇到了same problem . 但是我的应用程序在iOS 7上的工作方式不同 .

在视频结束或退出全屏时,应用程序旋转保持横向模式.i将设备手动旋转到纵向位置,然后应用程序变为正常定位位置(纵向),不再更改 . 但是在视频结尾处的ios 6中,设备方向会自动回到正常位置 .

有没有人有建议?

编辑:我刚刚意识到 . 我的应用程序状态栏在视频结尾处是纵向方向 . 然而,该观点持有景观位置 . 我尝试重复旋转,然后修正了视图 .

2 回答

  • 2

    在AppDelegate.h中:

    @property(nonatomic)BOOL allowRotation;
    

    在AppDelegate.m中:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
        RootViewController * root = [[RootViewController alloc] init];
        self.window.rootViewController = root;
    
    //add two Notification
    
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPVisionVideoNotification:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPVisionVideoNotification:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];
    
        self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
        return YES;
    }
    
    - (void) moviePlayerWillEnterFullscreenNotification:(NSNotification*)notification {
        self.allowRotation = YES;
    }
    
    - (void) moviePlayerWillExitFullscreenNotification:(NSNotification*)notification {
        self.allowRotation = NO;
    }
    
    -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
    {
        if (self.allowRotation) {
    
            return UIInterfaceOrientationMaskLandscapeRight ;
        }
        return UIInterfaceOrientationMaskPortrait;
    }
    
    //this can rotate the windows when to fullscreen state
    
  • 0

    最后,我解决了这个问题 . 我没有提到我曾经使用过第三方图书馆,这是“viewdeck II” . 它破坏了旋转周期 .

    我建议谁遇到这种问题,检查你的 3rd party 图书馆......

相关问题