iOS 10: UIWebView: can't change text size on iPad

In our production app, we can't seem to be able to change the text size of a UIWebView on iOS 10 on iPad.



We're using this method to change the text size:

[self.webview stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust = '%d%%'", size]];



Running our sample project, always running on iPad simulator with iOS 10:

(always running in iPad simulator, but switching Deployment device setting)

-On iOS9, built for iPhone device: works

-On iOS9, built for iPad device: works

-On iOS10, built for iPhone device: works

-On iOS10, built for iPad device: DOESN'T WORK, no resizing, no errors or warnings



We are aware of WKWebView, and there are similar issues, using similar methods, except that it doesn't work for both iPad and iPhone on iOS10, but works on iOS9.



Using Xcode 8 beta 2, on iPad simulator with iOS 10 beta 2 (also tried with iOS 10 beta 1).


(Update: still broken in iOS10 GM and iOS10.1b1)


Anyone have any ideas or alternatives?

Thanks!

Still broken in iOS10.1GM.

Everyone who have not file a bug report yet please do it to bring Apple's attention to the problem

https://bugreporter.apple.com/

Please report a Radar to Apple and refer to this thread and Radar #27201529, thanks!

Accepted Answer

Looks fixed in iOS10.2b1! I'll keep testing to confirm.

I don't think it's just for the iPad. I can't change it on my iPhone as well./: I'll try updating to the latest beta. Thanks for this information!

Anyone got a workaround for this?

Still fixed in iOS10.2b2 🙂

Hi,


Today our QA's Found this font size issue in our apps so i find the solution.


In Swift you can try following code its working as before:


let textSize: Int = 140

self.bodyContent.stringByEvaluatingJavaScript(from: "document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '\(textSize)%'")


Issue found in script before ios 10.3 update we are using textsize%% but from 10.3 ios update needs to use textsize% you only needs to remove one % sign from ur script. then it will working fine.


Thank You!

Nadeem

This worked great!! Thanks for the great tip 🙂

iOS 10: UIWebView: can't change text size on iPad
 
 
Q