【问题标题】:iOS - Video not rotating only in iOS7 over iPhone?iOS - 视频不能仅在 iOS7 上通过 iPhone 旋转?
【发布时间】:2013-10-06 07:16:02
【问题描述】:

我做了什么?

我在MPMoviePlayerViewController的扩展类中播放视频,并实现了定向功能如下

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

    if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
        return FALSE;
    }
    else{
        return TRUE;
    }
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    [self setControlsPositions:toInterfaceOrientation];
}
-(BOOL)shouldAutorotate
{
    return YES;
}

我面临什么问题?

该应用程序在 iPhone 和 iPad Almong 和 iPad(使用 iOS7)上运行良好,直到 iOS6,但视频不会在安装了 iOS7 的 iPhone 上旋转。

出现此类问题的原因是什么以及如何解决?

更新

我发现如果setMovieSourceType 是 设置为MPMovieSourceTypeUnknown,但设置为时不旋转 `MPMovieSourceTypeStreaming

【问题讨论】:

  • 您的结论显然听起来像是 MediaPlayer 框架中的一个错误(又一个错误)。我强烈建议使用您的最小化示例提交错误报告。
  • @Till 这似乎是一个不错的选择,但我在哪里发送错误报告。我的意思是给苹果发邮件或者在苹果论坛发帖?
  • apple website bug radar service。此外,在OpenRadar 上提交该文件可能是一个好主意。
  • +1 使问题清晰,标题正确
  • 请同时提交一份关于 OpenRadar 的报告,并让我们知道使用了哪个 ID。这将有助于确保开发者社区在任何进展上获得一定的透明度(否则无法直接通过 Apple 获得)。

标签: ios media-player ios7 mpmovieplayercontroller mpmovieplayer


【解决方案1】:

iOS 6 更改了旋转方法,您需要将 iOS 6 旋转方法添加到视图控制器:

- (BOOL)shouldAutorotate {
    return YES:
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

您需要将带有支持方向的Supported interface orientations 添加到您的应用info.plist

来自iOS 6.0 release的信息:

UIViewController 类具有支持以下内容的新接口 行为:

  • 新界面为管理和跟踪界面轮换提供了更清晰的路径。

【讨论】:

  • 另外,在 info.plist 中,除了 'UIInterfaceOrientationPortraitUpsideDown' 之外的所有屏幕方向都是允许的
  • 从 iOS 6 开始,如果您没有实现 shouldAutorotate,则假定该值为 YES。然后,如果旋转匹配任何受支持的旋转形式 info.plist 您的视图将被旋转。如果您实现上述方法,您的MPMoviePlayerViewController 子类将再次旋转。
  • 这不起作用我已经更新了问题..检查出来
  • 我不认为这个答案是完全错误的或研究不力或类似的东西。由于问题中未描述的事情,甚至可能由于其他地方的错误,它可能不适用。它当然不值得被否决。
【解决方案2】:

试试这个解决方案:

在您的AppDelegate.h

@property  (nonatomic, assign) BOOL *fullScreenVideoIsPlaying;

在您的AppDelegate.m

@synthesize fullScreenVideoIsPlaying;

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    NSUInteger orientations = UIInterfaceOrientationMaskPortrait;
    if (self.fullScreenVideoIsPlaying) {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }
    else {
        if(self.window.rootViewController){
            UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject];
            orientations = [presentedViewController supportedInterfaceOrientations];
        }
        return orientations;
    }}

在您的 ViewController:

viewDidLoad方法中:

    myDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieStarted:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinished:) name:@"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];

并将这两个方法添加到同一个类中:

-(void) movieStarted:(NSNotification*) notif {
     myDelegate.fullScreenVideoIsPlaying = YES;
}
-(void) youTubeFinished:(movieFinished*) notif {
     myDelegate.fullScreenVideoIsPlaying = NO;
}

【讨论】:

    【解决方案3】:

    我认为设备旋转被锁定在控制中心,导致它在 ipad ios 7 中运行良好。

    【讨论】:

      【解决方案4】:

      在苹果希望我给他们一个关于我在 iOS-7 中报告的错误的示例后,我发现我没有推送视图控制器,而是将视图添加到窗口。 在这种情况下,其他视图控制器确实获得了方向事件,但 MPMoviePlayerViewController 子类没有,所以我只是展示了视图控制器而不是添加它的视图并且它起作用了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-02-26
        • 2013-02-27
        • 1970-01-01
        • 2012-04-26
        相关资源
        最近更新 更多