2012-07-05 122 views
0

嗨我已經使iPhone應用程序之前,但即時通訊新混合應用程序只是想知道如何通過科爾多瓦訪問攝像機功能?我已經嘗試了幾個教程onlie,但似乎沒有發生,當我按下xcode中的按鈕它說收到內存警告。誰能幫忙?科爾多瓦1.7訪問攝像機

繼承人什麼我都試過到目前爲止

<!DOCTYPE html> 
<html> 
    <head> 
     <title>Capture Photo</title> 

     <script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script> 
     <script type="text/javascript" charset="utf-8"> 

      var pictureSource, 
       destinationType 

      document.addEventListener("deviceready",loaded,false); 

      function loaded() { 
       pictureSource=navigator.camera.PictureSourceType; 
       destinationType=navigator.camera.DestinationType; 
      } 

      function getPhoto(imageData) { 
       var smallImage = document.getElementById('smallImage'); 

       smallImage.style.display = 'block'; 

       smallImage.src = "data:image/jpeg;base64," + imageData; 
      } 

      function capturePhoto() { 
       navigator.camera.getPicture(getPhoto, onFail, { quality: 50 }); 
      } 

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

      </script> 
    </head> 
    <body> 
     <button onclick="capturePhoto();">Capture Photo</button> <br> 
     <img style="display:none;width:60px;height:60px;" id="smallImage" src="" /> 
    </body> 
</html> 
+0

是內存警告來每次你點擊按鈕? – dhaval 2012-07-05 16:55:46

回答

1

你默認爲它使用了太多的內存數據網址的回報。切換到文件uri。

function getPhoto(imageData) { 
    var smallImage = document.getElementById('smallImage'); 

    smallImage.style.display = 'block'; 

    smallImage.src = imageData; 
} 

function capturePhoto() { 
    navigator.camera.getPicture(getPhoto, onFail, { quality: 50, 
     destinationType: destinationType.FILE_URI }); 
}