【问题标题】:iPhone phonegap image disappearing after the phone sits for some time手机放置一段时间后,iPhone phonegap 图像消失
【发布时间】:2013-05-19 14:10:01
【问题描述】:

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

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

iOS 是否会在关闭并允许静置一段时间后重命名图像?有什么建议么?如果手机关闭并重新打开,则不会发生这种情况..仅在手机放置一段时间后...

这似乎非常相关...... Capturing and storing a picture taken with the Camera into a local database / PhoneGap / Cordova / iOS

【问题讨论】:

    标签: iphone ios image cordova uiwebview


    【解决方案1】:

    对于遇到此问题的其他人,以下代码对我有用...

        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);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多