2013-05-19 36 views
0

我在iOS上使用phonegap 2.0.0并基本上使用了股票图像捕获代码。捕获图像后,将其保存到手机中,将URI与其余项目信息一起保存到数据库,并且图像显示在页面上。iPhone phonegap图像在手机坐了一段时间后消失

所有这一切都适用于iOS和Android。问题是,当iOS手机关机并允许坐一段时间(过夜)时,图像不再显示。其余数据从数据库中检索并显示,但图像只显示图像应该显示的黑色方块(表示信息仍在数据库中)

iOS是否在关闭后重命名图像并允许坐一段时间?有什么建议么?如果手机被关闭并重新打开,这不会发生..手机坐了一段时间后,才...对别人有这个问题的

这看起来非常相关的... Capturing and storing a picture taken with the Camera into a local database/PhoneGap/Cordova/iOS

回答

0

下面的代码为我工作...

function capturePhoto() { 
navigator.camera.getPicture(movePic, onFail,{ quality : 70 }); 
} 

function movePic(file){ 
window.resolveLocalFileSystemURI(file, resolveOnSuccess, resOnError); 
} 

function resolveOnSuccess(entry){ 
var d = new Date(); 
var n = d.getTime(); 
var newFileName = n + ".jpg"; 
var myFolderApp = "myPhotos"; 
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) {  
fileSys.root.getDirectory(myFolderApp, 
       {create:true, exclusive: false}, 
       function(directory) { 
        entry.moveTo(directory, newFileName, successMove, resOnError); 
       }, 
       resOnError); 
       }, 
resOnError); 
} 
function successMove(imageUri) { 
    document.getElementById('smallImage').src = imageUri.fullPath; 
    //hidden input used to save the file path to the database 
    document.getElementById('site_front_pic').value = "file://"+imageUri.fullPath; 
    smallImage.style.display = 'block'; 
} 

function onFail(message) { 
alert('Failed to load picture because: ' + message); 
} 

function resOnError(error) { 
alert(error.code); 
} 
相关问题