Search code examples
iosobjective-cuiwebview

UIWebView and top bar iPhone 5 iPhone 4 scaling issue


This is my WebView .nib File

WebView Nib File

The grey space on top is need for a 44px high Navigation bar, which is defined programmatically in a super class of the WebView.

The content of the Webview looks and scales correctly in iPhone 5. However on the iPhone 4s, different screen size, it scales wrongly, so that I can't scroll entirely to the top.

I set the [email protected], Default.png and [email protected] as start screens, because I read it can prevent scaling issues.

I also set the WebViewController´s view, which is the view in the Nib File to

self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

but both doesn't work.


Solution

  • I think the answer lies with auto layout. That seems like something really easy to do with it. Are you limited to a version of iOS that doesn't support auto layout? If not, here's how to do it:

    enter image description hereenter image description hereenter image description here

    Using this method, no matter what size of screen you have, you'll always have a 44 pixel margin at the top.