Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebview content not at top of view

I have a iOS 9 screen with two UIWebviews on it; the two UIWebviews are set up the same in IB, and each displays an HTML table, with the same CSS. But the two views display differently: in the top one the table is scrolled down and shows a blank area at the top; the second one displays correctly.

The two HTML tables have a gray background to show their position here. Here's the view when it opens; there is a table in each of the outlined UIWebviews:

I can manually scroll the top view into the correct position:

Screen shot two

I would, of course, like the top UIWebview to present the table at the top of the view.

Any ideas on why the top UIWebview scrolls the table down when it opens? I've seen this in several other instances and have not been able to figure out why or how to correct it.

like image 462
johnz Avatar asked Sep 30 '15 15:09

johnz


1 Answers

Stonz2's link gave me the answer: add automaticallyAdjustsScrollViewInsets = false to the viewController's viewDidLoad method.

like image 80
johnz Avatar answered Sep 19 '22 02:09

johnz