UIWebView 下载它的图像内容

UIWebView download it's image content

本文关键字:图像 下载 UIWebView      更新时间:2023-09-26

我正在使用高图表在 Web 视图中的本机 iOS 应用程序中绘制图表问题是当我将图表导出为图像时,图像出现在 Web 视图中,我无法保存或下载它。

在桌面浏览器中,当我导出它时,它会立即开始下载。

导出机制是通过JS函数调用提供的,我从本机应用程序调用它

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

我对JS库进行了挖掘,发现他们向那里的服务器发送了一个post请求以获取图像,所以我没有可以下载的图像的URL!

我希望能够保存图像并将其传递给我的本机应用程序,任何帮助!!

提前感谢...

您有一个选项是将 Web 视图转换为图像。以下代码片段执行此操作:

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