As part of iOS9 we have the new method loadData() introduced into WKWebView.
I have NSData object that is output of UIImageJPEGRepresentation that I want to render in a WKWebView. Prior to iOS9, in order to render image in wkwebview, I was:
- storing nsdata on the local file system as a .jpeg file
- create a nsurl with fileWithUrl init method
- Call wkwebview.loadRequest(url) where url is the nsurl created in previous step
I was hoping take advantage of the new iOS9 method where I can directly call the wkwebview.loadData(nsdata, MIMEType:"image", characterEncoding:"ASCII", baseURL: NSURL("random"))
I am not able to render the image using the above loadData call. Could be issue with the params I am passing for MIMEType, characterEncoding and baseUrl. Could not find any examples for this method call anywhere.
Notes:
- I am not sure what characterEncoding to use when rendering image
- The baseUrl cannot be nil and so initialized it to a random url