在退出YouTube全屏后,将应用旋转至肖像

问题描述:

我的应用使用嵌入式YouTube播放器UIWebView,一切正常。除了离开全屏后应用的方向 - 它立即设置为肖像。自动旋转功能,因为用户可以通过将设备旋转到纵向和背面来轻松修复它。在退出YouTube全屏后,将应用旋转至肖像

它发生在模拟器(6.0,6.1,7.0)和设备(6.1.3)上。

对于我的需要,只需删除进入全屏的功能即可(按钮&捏手势),但这是不可能的,如果我没有弄错。使用html代码进行的实验没有任何结果。我知道,在全屏显示后,在根视图控制器上有viewWillAppear,viewDidAppear调用,但这些调用未被覆盖。通过以编程方式设置“固定”方向也是不可能的,因为iOS 6,对吧?

这是嵌入式播放器的HTML:

<html> 
    <head> 
     <style type=\"text/css\"> 
      iframe {position:absolute; top:0px; margin-top:0px;} 
      body {background-color:#000; margin:0;} 
     </style> 
    </head> 
    <body> 
     <iframe class=\"youtube-player\" type=\"text/html\" width=\"100%%\" height=\"100%%\" src=\"http://www.youtube.com/embed/%@?vq=hd720;HD=1;rel=0;showinfo=0" frameborder=\"0\" allowfullscreen=\"false\" showinfo=\"0\"> 
     </iframe> 
    </body> 
</html> 

感谢。

傻我。除去下面的代码固定它:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
    return UIInterfaceOrientationPortrait; 
} 

UIViewController文档:

If your view controller implements this method, then when presented, its view is shown in the preferred orientation (although it can later be rotated to another supported rotation). If you do not implement this method, the system presents the view controller using the current orientation of the status bar.

(重点煤矿)