2017-06-14 54 views
0

我有一个支持所有设备方向的主ViewController以及仅支持横向的视频播放器ViewController。支持所有方向的iOS ViewController在从横向返回后更改为横向ViewController

当设备的方向被解锁,并且我从视频返回到主ViewController时,它仍然根据我的设备的方向自动旋转。这是所需的行为。

但是,当设备的方向被锁定,并且我从纵向模式主视图控制器开始时,我从横向视频返回,现在主视图控制器被锁定到横向模式。这只发生在iOS 9+上。

我不确定它是相关的,但主ViewController继承Cordova的CDVViewController。这里是来自VideoPlayerViewController的方向相关的代码:

- (BOOL)shouldAutorotate{ 
    return YES; 
} 

- (NSInteger)supportedInterfaceOrientations{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ 
    return UIInterfaceOrientationLandscapeLeft; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
      interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

我很感激任何想法如何解决这个问题。谢谢!

+0

如何呈现视频视图...推送到UINavigationController或作为模态视图控制器? – Ladislav

回答

0

我认为它必须是CDVViewController改变方向的错。

如果在UIKit元素中使用常规UIViewController,并且设备的方向锁定比在设备取向锁定开启时从不从纵向切换到横向方向。

出于测试目的,尝试并用常规的UIViewController更换CDVViewController,只是添加一个按钮呈现VideoPlayerViewController,你看到对子级,它会留在肖像预期。

相关问题