iOS WebView 空白 [英] iOS WebView blank gap

查看:33
本文介绍了iOS WebView 空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用 youtube 的标准嵌入网址( 但提到的解决问题的功能要么不再存在,要么现在是私有的.我仍在寻找答案.

解决方案

我修好了.

 覆盖 func viewWillLayoutSubviews() {super.viewWillLayoutSubviews();playerWebView.scrollView.contentInset = UIEdgeInsetsZero;}

添加到我对问题所做的编辑中,我忘记了像在 C# 中一样快速更改设置和获取访问器变量的方法.

I have embedded a Youtube video in my iOS 8.3 app using youtube's standard embed url (sample) which is working as expected but looking pretty weird. That white gap (blue zone on the view tree inspector) should not be there.

I can confirm it's not a CSS issue as the inspector shows it is effectively occupying 100% width and height of the uiWebView component.

I have setup constraints to the left, top and right borders to equate the window/layout guides so that's not the problem either. It seems a private _UIWebViewScrollView component is taking all the height i assigned to the UIWebView, and pushing the real content (UIWebViewBrowserView) to the bottom of said area.

I looked up info on the scroll view class but it seems there's only header files scattered on the web with no real apple docs so i'd rather not mess with that scroll view if possible.

Seems my hunch is right, the same problem was described by someone on another question also regarding a scrollview but the mentioned function to fix the problem either does not exist anymore or is now private. I'm still looking for answers.

解决方案

I fixed it.

  override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews();

    playerWebView.scrollView.contentInset = UIEdgeInsetsZero;
  }

Adding to the edit i made to the question, i forgot swift changes set and get methods for accessor variables as in C#.

这篇关于iOS WebView 空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆