2013-09-30 45 views
15

我做了什么?iOS - 视频不能仅在iOS7上通过iPhone旋转?

我在玩视频在扩展类的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上的iOS6上运行良好Almong使用iPad(使用iOS7),但视频不通过安装iOS7的iPhone旋转。

这种问题的原因是什么以及如何解决?

更新

我发现,在影片结束旋转如果setMovieSourceType是 设置为MPMovieSourceTypeUnknown但是,当设置为 `MPMovieSourceTypeStreaming

+0

您的结论听起来像是MediaPlayer框架中的一个错误(又一个错误)。我强烈建议使用最小化的示例提交错误报告。 – Till

+0

@Till这似乎是一个不错的选择,但我在哪里发送错误报告。我的意思是发送电子邮件到苹果或在苹果论坛发帖? –

+1

关于[苹果网站bug雷达服务](https://bugreport.apple.com)。另外,在[OpenRadar](http://openradar.appspot.com/)上也可能是一个好主意。 – Till

回答

3

当苹果想让我给他们一个iOS-7报告的bug的样本后,我发现我并没有推视图控制器,而是将视图添加到窗口。 在这种情况下,其他视图控制器确实获取方向事件,但MPMoviePlayerViewController子类没有,所以我只是介绍视图控制器,而不是添加其视图,它的工作。

0

旋转方法改变不旋转在iOS 6中,您需要将iOS 6旋转方法添加到视图控制器:

- (BOOL)shouldAutorotate { 
    return YES: 
} 

- (NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskAllButUpsideDown; 
} 

而且您需要将支持的方向添加到Supported interface orientations到您的应用程序info.plist

iOS 6.0 release信息:

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

  • 新接口提供了管理和跟踪界面旋转更清晰的路径。
+0

但它的工作正常在iOS6和iOS7在iPad –

+1

此外在信息。 plist除了'UIInterfaceOrientationPortraitUpsideDown'外允许所有屏幕方向 –

+0

如果您没有实现['shouldAutorotate'](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/) Reference.html#// apple_ref/doc/uid/TP40006926-CH3-SW124),该值被认为是“YES”。然后,如果旋转与任何支持的旋转形式“info.plist”相匹配,那么您的视图就会旋转。如果你实现上述方法,你的'MPMoviePlayerViewController'子类将再次旋转。 – rckoenes

1

尝试这种解决方案:

在你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; 
    }} 

在您的视图控制器:

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; 
} 
0

我认为设备旋转被锁定在控制中心因为它在iPad等iOS 7运行良好。