【问题标题】:UIWebView download it's image contentUIWebView 下载它的图片内容
【发布时间】:2013-01-27 14:19:51
【问题描述】:

我正在使用high charts 在 Web 视图的原生 iOS 应用程序中绘制图表 问题是当我将图表导出为图像时,图像出现在网络视图中,我无法保存或下载。

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

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

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

我深入研究了 JS 库,发现他们向那里的服务器发送了一个发布请求以获取图像,所以我没有可以下载的图像的 URL!

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

提前谢谢...

【问题讨论】:

    标签: javascript ios uiwebview highcharts


    【解决方案1】:

    您有一个选择是将您的网络视图转换为图像。下面的 sn-p 做到了:

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

    【讨论】:

    • 我想使用JS函数,因为它们提供了很多格式的导出,png,jpg,pdf,我要添加excel
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-13
    • 1970-01-01
    • 2012-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-12
    相关资源
    最近更新 更多