Phonegap 2.9.0中的摄像头无法正常工作

时间:2013-09-02 13:38:13

标签: ios cordova camera phonegap-plugins

我正在为我的iPhone应用程序使用带有Camera API的PhoneGap 2.9.0。当我调用该方法时,它无效。这是我的代码:

应用/支持文件/ Cordova.plist

<key>Plugins</key>
<dict>
<key>Camera</key>
<string>CDVCamera</string>
</dict>

config.xml中

<plugin name="Camera" value="CDVCamera" />

关于捕获方法

function capturePhoto() {
navigator.camera.getPicture(onPhotoURISuccess, fail, {
    quality: 50,
    destinationType: Camera.DestinationType.FILE_URI
});
}
function onPhotoURISuccess(imageURI) {
Ext.Viewport.setMasked({
    xtype: 'loadmask',
    message: 'Loading..',
    indicator: true
});
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
options.mimeType = "image/jpeg";

var params = new Object();
params.value1 = "Fastabuy";
options.params = params;
options.chunkedMode = false;

var URL = imguploadurl + 'pid=&type=single';
//console.log(URL);
var ft = new FileTransfer();
ft.upload(imageURI, URL, win, fail, options);
/*attendphoto=imageURI;         
             document.getElementById('productpic').src = attendphoto; 
             App.gvars.Productimg=attendphoto;  
             //console.log( App.gvars.Productimg);*/
 }


var captureSuccess = function (mediaFiles) {
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
    fpath = mediaFiles[i].fullPath;
    fimage = mediaFiles[i].name;
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotimg, fail);
}
};

我不知道我的代码有什么问题。请帮我解决一下。

1 个答案:

答案 0 :(得分:0)

确保您在index.html中引用新的phonegap / cordova.js文件,例如 <script src="phonegap.js"></script> 在构建应用程序时,它会与index.html放在同一目录中。

  • WWW \
  • - index.html
  • - phonegap.js
  • - img \
  • - css \
  • - js \
  • ...