iOS7 Webview initial scroll position under Navigation bar

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

    My solution:

    - (void)loadView {
        ...
    
        _offsetSet = NO;
    }
    
    - (void) viewDidLayoutSubviews {
    
        if (!_offsetSet) {
            [_webView.scrollView setContentOffset:CGPointMake(0, -self.topLayoutGuide.length) animated:NO];
        }
    }
    
    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
    
        _offsetSet = YES;
    }
    

提交回复
热议问题