如何摆脱 UIWebview 中的 adjustedContentInset?
How to get rid of adjustedContentInset in UIWebview?
我有一个 UIWebView
,我从远程 URL 加载内容。我面临的问题是,webview 内容的最后一部分不可滚动。调试时我注意到 adjustedContentInset
设置为 {0, 0, 49, 0}
。也许这就是部分 webview 内容(距末尾 49 点)不可滚动的原因。有什么办法可以去掉 adjustedContentInset
以便整个内容都可以滚动吗?
我尝试将 webview 的滚动视图 contentInsets
设置为 {0,0,0,0} 但没有帮助。
UITableView
和 UICollectionView
有 contentInsetAdjustmentBehavior
重置 adjustedContentInset
的方法,但我找不到 UIWebView
的 属性。
任何帮助将不胜感激。
实际上,contentInsetAdjustmentBehavior
是 UIScrollView
属性,这就是为什么你提到:
UITableView
and UICollectionView
has contentInsetAdjustmentBehavior
method to reset adjustedContentInset but i couldn't find such property
for UIWebView
.
正确。
这意味着 contentInsetAdjustmentBehavior
是 而不是 一个 属性 对于 UIWebView
(UIView
),你需要什么要做的是通过网络视图访问它 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 = ...
应该可以。
我有一个 UIWebView
,我从远程 URL 加载内容。我面临的问题是,webview 内容的最后一部分不可滚动。调试时我注意到 adjustedContentInset
设置为 {0, 0, 49, 0}
。也许这就是部分 webview 内容(距末尾 49 点)不可滚动的原因。有什么办法可以去掉 adjustedContentInset
以便整个内容都可以滚动吗?
我尝试将 webview 的滚动视图 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
),你需要什么要做的是通过网络视图访问它 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 = ...
应该可以。