iOS7 Webview initial scroll position under Navigation bar

后端 未结 8 2589
[愿得一人]
[愿得一人] 2021-02-18 22:50

I have a webview which is scrolling as desired underneath a navigation bar.

However, when I first load the controller, the page loaded in the webview is scrolled so that

8条回答
  •  感动是毒
    2021-02-18 23:31

    Rick's answer is correct except the top value should be negative, this is what worked for me!

    [self.webView.scrollView setContentInset:UIEdgeInsetsMake(-44, 0, 0, 0)];
    [self.webView.scrollView setScrollIndicatorInsets:UIEdgeInsetsMake(-44, 0, 0, 0)];
    [self.webView.scrollView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];
    

    I used -44, if you don't have status bar on the top you should use -64.

提交回复
热议问题