我通过将 iFrame 加载到 UIWebView 来显示 YouTube 视频(以及其他类型的视频,如 dailymotion)。
这是 iFrame 字符串:
let iFrameHtmlString = String(format:"<iframe class=\"youtube-player\" type=\"text/html\" width=\"100%%\" height=\"300\" src=\"https://www.youtube.com/embed/%@?autoplay=1\" frameborder=\"0\"></iframe>", youtubeId)
我将它加载到 UIWebView 中:
webView.loadHTMLString("<body>" + iFrameHtmlString + "</body>", baseURL: nil)
- 当我点击视频时,视频以全屏模式启动。
- 然后我以横向模式旋转设备
- 然后我将设备旋转回纵向模式
- 然后我离开全屏模式
=> 我的状态栏已经消失,直到我终止应用程序并重新启动它才会出现。
知道如何解决这个问题吗?
最佳答案
最后,我解决了将 UIViewControllerBasedStatusBarAppearance 设置为 YES(之前为 NO)的问题,因此状态栏外观不受 iFrame 显示的全屏 View Controller 的影响。
关于ios - iframe 自动全屏使状态栏消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42701298/