Software and Technology Ramblings

September 22, 2010

UIWebView too wide after rotation from Landscape

Filed under: iPhone Development — Tags: , — Doug Hays @ 9:04 am

I had the simplest of UIWebView implementations throwing me an odd issue. It was an iPad app with a UIWebView, stretched to fill the entire screen, loaded from a local HTML file.

If the view was loaded in landscape and then rotated to portrait, the content size of the web view would remain at 1024 pixels wide even though the HTML content only took up 700px.

I finally found a helpful post that suggested I add the following inside the HEAD tag of my HTML:

<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">

That does the trick!

Powered by WordPress