iOS webview leaves empty space before HTML content

只愿长相守 提交于 2019-12-06 06:29:30

iOS adjusts the content inset only for the first view in the view hierarchy if it is UIScrollView or it's descendant (e.g. UITableView and UICollectionView, in your case its a UIWebView). If your view hierarchy includes multiple scroll views, automaticallyAdjustsScrollViewInsets will make adjustments only to the first one.

Here's how to change this behavior:

a) Interface Builder

Select the view controller Open Attributes inspector There's a property called "Adjust scroll view insets" in IB's attribute inspector (when a ViewController is selected) which is on by default.

b) Programmatically

Add this to i.e. viewDidLoad method

Obj-C: self.automaticallyAdjustsScrollViewInsets = NO;

Swift: self.automaticallyAdjustsScrollViewInsets = false

Turn off adjusts scroll view insets.It's here:

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