UIWebBrowserView does not span entire UIWebView

不问归期 提交于 2019-12-01 05:07:09
ilya

I've encountered with the same problem. And found simple fix. The culprit is UIViewController's property automaticallyAdjustsScrollViewInsets. UIViewController reference says:

Default value is YES, which allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar.

It means that UIViewController adds that top gap to UIWebView's scroll view even if you properly set up webview frame or add autolayout constraints. To overcome this behaviour just

Set to NO if you want to manage scroll view inset adjustments yourself, such as when there is more than one scroll view in the view hierarchy.

"manage scroll view inset adjustments your self" in our context means that we won't add any insets ;)

same issue with any scroll view, i.e. Blank space at top of UITextView in iOS 10 https://stackoverflow.com/search?q=automaticallyAdjustsScrollViewInsets

This issue has also resurfaced with iPhone X.

With iOS 11, UIScrollView now has the property contentInsetAdjustmentBehavior.

webview.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

can correct this issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!