【问题标题】:MPMoviePlayerController can rotate in full screen while the Application only supports portrait orientation in ios 7MPMoviePlayerController 可以全屏旋转,而应用程序在 ios 7 中仅支持纵向
【发布时间】:2013-12-15 15:02:03
【问题描述】:

我在这里面对same problem。但是我的应用程序在 iOS 7 上的运行方式不同。

在视频结束或退出全屏时,应用程序旋转保持横向模式。我手动将设备旋转到纵向位置,然后应用程序变为正常方向位置(纵向)并且不再改变。但在 ios 6 中,视频结束时,设备方向会自动恢复到正常位置。

有人给点建议吗?

编辑:我现在才意识到。我的应用程序状态栏在视频结尾处是纵向的。但是,视图保持横向位置。我尝试反复旋转,之后视图更正。

【问题讨论】:

  • 是的,你可以试试 modelpresentclass
  • 在 ios 7 中是否已弃用?
  • 顺便说一句,我已经尝试过modelpresentclass。它也没有用。请注意编辑

标签: ios objective-c iphone ios7 mpmovieplayercontroller


【解决方案1】:

在 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

【讨论】:

  • 我在另一个回复中发现了这个sn-p,我用它来解决同样的问题。不幸的是,我不得不将你连根拔起,而不是原作者。
【解决方案2】:

最后,我解决了这个问题。我没有提到我已经使用了“viewdeck II”的第 3 方库。它打破了旋转周期。

我建议谁遇到这种问题,检查您的第三方库...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-23
    • 2018-09-07
    相关资源
    最近更新 更多