我'm using SWRevealViewController and my app is locked on portrait orientation. On one of my view controllers I'使用 YTPlayerView
启动了一个youtube播放器 . 在显示视频时,我会以编程方式将方向切换为横向,如下所示:
let value = UIInterfaceOrientation.LandscapeLeft.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
在退出视频时,像这样回到肖像:
let value = UIInterfaceOrientation.Portrait.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
一切正常,但引入了布局问题:导航栏Y没有被状态栏偏移,导致状态栏位于导航栏的顶部(参见屏幕) .
Before orientation change
Playing video on landscape orientation
Navigation bar is being obscured by the status bar
我在这里缺少什么:)?
1 回答
声明一个将缓存初始导航栏大小的var
然后,在viewDidLoad中保存默认值
更改方向后调用此方法解决问题:
该解决方案的灵感来自@Shlomi