2012-07-05 96 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 }); 
}