iOS7 Webview initial scroll position under Navigation bar

后端 未结 8 2604
[愿得一人]
[愿得一人] 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:33

    The way I solved this issue is with the webViewDidFinishLoad delegate callback. In the callback method for the web view I set do all the work to make the web view's scroll view look correct.

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

提交回复
热议问题