I am using a split view controller with a UIWebView in the details view. On the iPhone 6 Plus, in landscape orientation, when I dismiss the master view to expand the details view to fit the whole screen, the content of the UIWebView gets stretched rather than resized to take advantage of the additional real estate.
How can I get the UIWebView to adjust the width of the content rather than stretching/zooming it when the the popover is dismissed?
(I was originally using a UITextView in the details view and converting the HTML string to an NSAttributedString. I didn't have the stretching issue with that, but the scrolling was choppy, etc., with large amounts of text. The UITextView works much better in this regard, with the stretching being the only issue.)
Prior to dismissing popover:
After dismissing popover:
EDIT: Here the string format I am using for the content displayed in the UIWebVIew:
private static let formatStringForUIWebView: NSString =
"<html>" +
"<head>" +
" <title></title>" +
" <meta name=\"viewport\" content=\"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0\" />" +
" <style type=\"text/css\">" +
" pre { width: auto; white-space: pre-wrap; }" +
" </style>" +
"</head>" +
"<body>" +
" <div style='color: #555555; font-size: 12px; font-family: Helvetica;'>%@</div>" +
"</body>" +
"</html>";
This might be what you're looking for. It prevents font scaling.
-webkit-text-size-adjust: none;
Here is a reference link to this css property.
https://developer.mozilla.org/en-US/docs/Web/CSS/text-size-adjust