0

I am trying to replace deprecated UIWebView with WKWebView. But during implementation I found out that WKWebView's loadData is not working properly and shows blank page when trying to render XML data which is encoded into UTF8. I have xsl transformation files in my Xcode project directory.

NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSData *xmlData = [self.invoiceXML dataUsingEncoding:NSUTF8StringEncoding];
[_webView loadData:xmlData MIMEType:@"text/xml" characterEncodingName:@"utf-8" baseURL:baseURL];

Previous working function with UIWebView

[_webView loadData:xmlData MIMEType:@"text/xml" textEncodingName:@"utf-8" baseURL:baseURL];

  • What was the working `UIWebView` previous code? Not sure if it's still valid, but https://stackoverflow.com/a/35074089/1801544 (see the comments) ? – Larme Oct 25 '22 at 07:43
  • Previously it was this [_webView loadData:xmlData MIMEType:@"text/xml" textEncodingName:@"utf-8" baseURL:baseURL]; – Adeel kiani Oct 26 '22 at 05:27

0 Answers0