Ios 感觉我在追求错误的解决方案…可能是我在会话存储方面的错误。请注意,cordova文档中指出,localStorage提供了到W3C存储接口的接口。它允许将数据保存为键值对。注意:window.sessionStorage提供相同的界面,但在应用程序启动之间

Ios 感觉我在追求错误的解决方案…可能是我在会话存储方面的错误。请注意,cordova文档中指出,localStorage提供了到W3C存储接口的接口。它允许将数据保存为键值对。注意:window.sessionStorage提供相同的界面,但在应用程序启动之间,ios,iphone,jquery-mobile,cordova,Ios,Iphone,Jquery Mobile,Cordova,感觉我在追求错误的解决方案…可能是我在会话存储方面的错误。请注意,cordova文档中指出,localStorage提供了到W3C存储接口的接口。它允许将数据保存为键值对。注意:window.sessionStorage提供相同的界面,但在应用程序启动之间被清除。所以,请尝试另一种解决方案,并使用localStorage保存图像路径,然后尝试从中检索 <div id="Ccamera-fun" data-role="page" data-title="Camera Fun Activity


感觉我在追求错误的解决方案…可能是我在会话存储方面的错误。请注意,cordova文档中指出,localStorage提供了到W3C存储接口的接口。它允许将数据保存为键值对。注意:window.sessionStorage提供相同的界面,但在应用程序启动之间被清除。所以,请尝试另一种解决方案,并使用localStorage保存图像路径,然后尝试从中检索
<div id="Ccamera-fun" data-role="page" data-title="Camera Fun Activity">
  <header data-role="header" data-theme="e" data-position="fixed">
      <a href="#" data-rel="back" data-theme="h" data-icon="arrow-l" data-direction="reverse">Back</a>
      <h1>3.5 years - 4.5 years</h1>
  </header>
  <div data-role="content" data-theme="a" class="content">
   <h1>Camera Fun</h1>
   <div id="imageContainer"></div>
    <img width="99%" id="imgProfile" src="" />
   <p>Use your photos and ask your child to describe one in detail. Use your photos as picture talks where your child can share their memories and recall events before or after the photo was taken. <strong>Together you could invent their own story.</strong></p>
    <p>Use the buttons below to take a picture with your phone or select an image from your phone&rsquo;s Photo Library. Once you have selected a photo, it will be embedded into the top of this screen.</p>

<script type="text/javascript" charset="utf-8">
// A button will call this function
//
function takePhoto() {
    sessionStorage.removeItem('imagepath');
    // Take picture using device camera and retrieve image as base64-encoded string
    navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI });
}

function onPhotoDataSuccess(imageURI) { 
        // Uncomment to view the base64 encoded image data
        // console.log(imageData);

        // Get image handle
        //
        var imgProfile = document.getElementById('imgProfile');

        // Show the captured photo
        // The inline CSS rules are used to resize the image
        //
        imgProfile.src = imageURI;
        imgProfile.style.display = 'block';
        imgProfile.style.border = '2px solid #ccc';
        imgProfile.style.marginTop = '10px';
        if(sessionStorage.isprofileimage==1){
            getLocation();
        }
        movePic(imageURI);
}

// Called if something bad happens.
// 
function onFail(message) {
    alert('Failed because: ' + message);
}

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

//Callback function when the file system uri has been resolved
function resolveOnSuccess(entry){ 
    var d = new Date();
    var n = d.getTime();
    //new file name
    var newFileName = n + ".jpg";
    var myFolderApp = "MyAppFolder";

    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) {      
    //The folder is created if doesn't exist
    fileSys.root.getDirectory( myFolderApp,
                    {create:true, exclusive: false},
                    function(directory) {
                        entry.moveTo(directory, newFileName,  successMove, resOnError);
                    },
                    resOnError);
                    },
    resOnError);
}

//Callback function when the file has been moved successfully - inserting the complete path
function successMove(entry) {
    //Store imagepath in session for future use
    // like to store it in database
    sessionStorage.setItem('imagepath', entry.fullPath);
}

function resOnError(error) {
    alert(error.code);
}

</script>
   <button onclick="takePhoto();" data-theme="h">Take a Picture</button>
 </p>
    <p><img src="img/DETE-footer.png" width="320" class="footer" /></p>
  </div>
</div>