I have a UIViewController designed in a Storyboard (IB) as follows :
What I want to happen when the VC loads is for the top of the UIWebView content to be positioned immediately below the navigation bar, and allow the user to scroll the content up the screen under the navigation bar (same as how the Dropbox app works when viewing PDFs). I have tried various attempts at this including using :
[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];
but I can't get it working - I just end up with the content starting at the top of the screen, underneath the navigation bar. I'm wondering if AutoLayout is preventing this working?
I had the same issue and fixed it. The solution is pretty simple:
Go to the storyboard, select the view controller which contains your UIWebView and open the Attributes Inspector. Here, you'll see the title "Extend Edges", just uncheck the box "Under Top Bars" and I will work !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With