ios - 如何摆脱 UIWebview 中的 adjustedContentInset?

标签 ios swift uiscrollview uiwebview

我有一个 UIWebView,我在其中从远程 URL 加载内容。我面临的问题是,webview 内容的最后一部分不可滚动。调试时我注意到 adjustedContentInset 设置为 {0, 0, 49, 0}。也许这就是部分 webview 内容(距末尾 49 点)不可滚动的原因。有什么方法可以摆脱 adjustedContentInset 以便整个内容都可以滚动吗?

我尝试将 webview 的 ScrollView 的 contentInsets 设置为 {0,0,0,0} 但它没有帮助。

UITableViewUICollectionViewcontentInsetAdjustmentBehavior 方法来重置 adjustedContentInset 但我找不到这样的属性 UIWebView.

我们将不胜感激。

最佳答案

实际上,contentInsetAdjustmentBehaviorUIScrollView 属性,这就是您提到的原因:

UITableView and UICollectionView has contentInsetAdjustmentBehavior method to reset adjustedContentInset but i couldn't find such property for UIWebView.

是正确的。

这意味着 contentInsetAdjustmentBehavior 不是 UIWebView (UIView) 的属性,您需要要做的是通过 WebView 访问它 scrollView属性:

The scroll view associated with the web view.

Discussion

Your app can access the scroll view if it wants to customize the scrolling behavior of the web view.

您的目标到底是什么。因此:

webView.scrollView.contentInsetAdjustmentBehavior = ...

应该可以。

关于ios - 如何摆脱 UIWebview 中的 adjustedContentInset?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49749426/

相关文章:

jquery ui 对话框未出现在带有 Google Maps v3 的页面上

ios - 如何在 Swift 4 中验证 JSON?

ios - 谷歌网址缩短器 iOS

ios - UIScrollView 的 contentOffset 在 vi​​ewDidLayoutSubviews 之后被重置

iphone - 内容定位到 UIScrollView 中

ios - ImageView 可以根据它在 iOS 中包含的图像自行调整大小

ios - 需要将 .MP4 文件从文档文件夹保存到照片库,但 Assets url 返回 nil

swift - 在实现测量扩展中,我们可以使用通用的 UnitType 吗?

ios - 为什么我的 [UIScrollView removeFromSuperview] 崩溃了?

ios - 模拟器上的苹果 map