UIWebview scalesPageToFit is not working properly when running an iPhone app on iPad with iOS 7.
I set the scalesPageToFit = YES before loading the request to the WebView.
After the page loads, inspecting the HTML document width gives 769px while the UIWebView's scroll view frame width is 320. The scroll view zoomScale is 1 although you would expect it to be 0.41... (320/769). Any idea?
The problem is now fixed in iOS 7.0.3. But, if you can't go there, please read on.
This seems to be a defect in iOS7. To recap, the problem happens when you run a iPhone only app, compiled with iOS7 SDK, in a iOS7 iPad or iPad Mini. A temporary work around is to scale the scroll view of the web view. This makes the text look smaller than you will like, but, so far, this is the best solution I have seen.
- (void)webViewDidFinishLoad:(UIWebView *)webView {
CGSize contentSize = webView.scrollView.contentSize;
CGSize viewSize = self.view.bounds.size;
float scale = viewSize.width / contentSize.width;
if (scale < 0.9) {
NSLog(@"Zoom out fix for web view: %f", scale);
webView.scrollView.minimumZoomScale = scale;
webView.scrollView.maximumZoomScale = scale;
webView.scrollView.zoomScale = scale;
}
}
We have an ios-app and a webapp with the same integration problem. We had to solve this in the webapp by enforcing the 320 css. I consider this an ios7 bug and would expect a fix for this.
Same problem: https://twitter.com/lukew/status/380702676121825280
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