ios 11/xcode 9上的UIWebView灰色空间上边距

ibm*_*123 1 xcode uiwebview ios

在此输入图像描述

在此输入图像描述

自更新到ios 11和xcode 9后,我无法从视图顶部显示html内容.似乎uiwebview的内嵌边距为20像素

有谁知道如何解决它?

谢谢

ibm*_*123 10

这解决了这个问题

[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
Run Code Online (Sandbox Code Playgroud)

参考: 如何摆脱UIWebView上的状态栏背景?


nul*_*ube 6

它仅适用于iOS 11+,因此:

if (@available(iOS 11.0, *)) {
    _webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
    // Fallback on earlier versions
}
Run Code Online (Sandbox Code Playgroud)