iOS UIWebview auto resize/scaling
I'm attempting to re-work the orientation handling functionality of an app, having a bit of trouble. I have a UIWebview
that is the only view visible at all times. The UIWebview
renders custom HTML pages that will always have fixed body size, matched to the screen resolution of the device. So for example, there might be an iPad portrait page with body size 768x1024, and a landscape page would be 1024x768. When the device is being held in Portrait orientation, and displaying a portrait page, the UIWebview
should display the page at full screen resolution. When the device is being held in landscape orientation and displaying a portrai开发者_运维技巧t page, I would like the UIWebview
to automatically scale to fit the screen vertically, and be centered horizontally. Vice versa with landscape pages while being held in portrait orientation. Basically, I want the page being displayed to always have the correct aspect ratio, regardless of size, while being centered in the screen.
I am sure there is some combination of the autosize settings in IB that will accomplish this, but I cannot seem to find the right setup. I have a mostly working solution that manually resizes and positions the UIWebView
frame after a page load or orientation change, but it occasionally acts up and doesn't display properly. It seems like this ought to be possible using the auto size/scale properties of the view itself.
Any help would be greatly appreciated.
Thanks in advance
精彩评论