IOS7 UIWebView has poor scroll insertion on initial load

advertisements

Whenever I display a PDF file in my webView it looks like it's initial scrollview inset is not set correctly but as soon as I start scrolling or zooming, it jumps to it's correct place :/

The PDF is loaded but it's partially under the navigation bar

As soon as I start scrolling or zooming in, it snaps to it's intended default position

If I load PNGs into the same webview they have the perfect inset and are displayed right under the navigation bar (not a line of black pixels in between).

Does anyone know how I can solve this?

Some of the webView settings:

webView.clipsToBounds = NO;
webView.scalesPageToFit = YES;


I implemented this workaround:

- (void)webViewDidFinishLoad:(UIWebView *)aWebView {

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.15 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        self.webView.scrollView.contentOffset = CGPointMake(0, -(self.webView.scrollView.contentInset.top));
    });

}

It "jumps" a bit when the WebView is loaded, but at least the contentOffset is set correctly. You might also need to fine tune the delay (0.15 ms in this example).