我有一个 UIWebView
,我在其中从远程 URL 加载内容。我面临的问题是,webview 内容的最后一部分不可滚动。调试时我注意到 adjustedContentInset
设置为 {0, 0, 49, 0}
。也许这就是部分 webview 内容(距末尾 49 点)不可滚动的原因。有什么方法可以摆脱 adjustedContentInset
以便整个内容都可以滚动吗?
我尝试将 webview 的 ScrollView 的 contentInsets
设置为 {0,0,0,0} 但它没有帮助。
UITableView
和 UICollectionView
有 contentInsetAdjustmentBehavior
方法来重置 adjustedContentInset
但我找不到这样的属性 UIWebView
.
我们将不胜感激。
最佳答案
实际上,contentInsetAdjustmentBehavior
是 UIScrollView
属性,这就是您提到的原因:
UITableView
andUICollectionView
hascontentInsetAdjustmentBehavior
method to reset adjustedContentInset but i couldn't find such property forUIWebView
.
是正确的。
这意味着 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/