UIWebBrowserView does not span entire UIWebView

前端 未结 2 953
闹比i
闹比i 2021-01-12 14:39

So I have been trying to get this simple behavior working on my iPhone app now for a while. I have a nav bar at the top and a tab bar at the bottom. I am loading all of my c

相关标签:
2条回答
  • 2021-01-12 15:05

    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

    0 讨论(0)
  • 2021-01-12 15:26

    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.

    0 讨论(0)
提交回复
热议问题