coder coder - 16 days ago 5
Objective-C Question

html font size manipulation on uiWebview is failing for latest iOS update

HY I have been using this function for ages and no problem was faced, on the latest iOS update it stopped working, on execution the font size doesn't change.
Any idea what could be the reason and how it could be fixed?

- (void)changeFontSize:(int)font {
NSLog(@"changeFontSize %i", font);
NSString *jsString = [NSString stringWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%d%%'", font];
[readingWebView stringByEvaluatingJavaScriptFromString:jsString];}


After further testing I have noticed that this problem only occurs on iPad iOS 10.1.1, but it works correctly on iPhone 10.1.1.

Answer

Okey this is a known issue and has an open radar here , but is reported to be fixed in iOS 10.2 beta 1 and in iOS 10.2 beta 2, so you will just have to wait, or you can try some of the solutions proposed on the radar, like enabling text auto resizing like so

[[[webView.scrollView.subviews.firstObject webView] preferences] _setTextAutosizingEnabled:YES];

hope this helps !

Comments