UIWebView is loading image content

I am using tall charts to draw charts in a native iOS app in a web view the problem is when i export the chart as an image, the image appears in the web view and I cannot save or load it.

in my desktop browser, when I export it, it starts loading immediately.

the export mechanism is provided through a JS function call, I call it from my own application using

[_webView stringByEvaluatingJavaScriptFromString:@"chart.exportChart({ type: 'image/jpeg', filename: 'chart'});"]);

      

I did some digging in the JS library and I found that they are posting a request to the server to get the image, so I don't have a URL for the image that I can upload with it.

I want to save the image and transfer it to my native app, any help!

thanks in advance...

+3


source to share


1 answer


One option is to convert your web view to an image. The following snippet does it:



UIGraphicsBeginImageContext(webview.bounds.size);
[webview.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

      

+2


source







All Articles