gpt4 book ai didi

ios - Cordova 截图插件 : doesn't work on iOS

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:24:54 25 4
gpt4 key购买 nike

我正在使用 Cordova 6.4.0 和插件 com.darktalker.cordova.screenshot 0.1.5“屏幕截图”。这是我的简单代码

    navigator.screenshot.save(function(error, res)
{
if(error)
{
alert(error);
}

else
{
alert(res.filePath); //just to see the path

}
}, 'jpg');

该代码适用于 android:屏幕截图已截取并保存,因此我可以使用它。但是,它在 iOS 上不起作用:我找不到屏幕截图。我该如何解决?

最佳答案

编辑2:

要将图像保存到照片库,请使用此插件:

https://www.npmjs.com/package/cordova-save-image-gallery

https://github.com/agomezmoron/cordova-save-image-gallery/blob/master/README.md

使用插件和截图插件保存图片。

navigator.screenshot.URI(function(error,res){

if(error){

console.error(error);

}else{

var params = {data: res, prefix: 'myPrefix_', format: 'JPG', quality: 80, mediaScanner: true};

window.imageSaver.saveBase64Image(params, function (filePath) {

console.log('File saved on ' + filePath);

},
function (msg) {

console.error(msg);

}

);

}
}, 'jpg', 50);

编辑:

我认为我没有正确理解这个问题。

我认为您无法在 iOS 上导航到该目录。相反,您需要将数据作为 URI 获取,并使用相机插件之类的东西将其存储在照片库中。

也就是说,如果您正在尝试查看图像?我认为该插件旨在仅向您返回屏幕截图并将其保存在应用程序的临时目录中。显示图像或将其存储在其他位置由您决定。

原始答案

我认为问题是 iOS 只使用 jpg 并且不期望“jpg”参数。尝试将您的代码更改为

    navigator.screenshot.save(function(error, res)
{
if(error)
{
alert(error);
}

else
{
alert(res.filePath); //just to see the path

}
});

关于ios - Cordova 截图插件 : doesn't work on iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43365486/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com