【问题标题】:Camera in Phonegap 2.9.0 not workingPhonegap 2.9.0 中的相机不工作
【发布时间】:2013-09-02 13:38:12
【问题描述】:

我将 PhoneGap 2.9.0 与我的 iPhone 应用程序的 Camera API 一起使用。当我调用该方法时,它不起作用。这是我的代码:

应用程序/支持文件/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);
}
};

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

【问题讨论】:

  • 你能解释一下“它不工作”是什么意思吗?究竟是什么错误?
  • @AndrewLively 它没有打开画廊或相机。当我点击
  • @Fazil 嘿,你有解决方案吗?请帮助我,这对我来说非常紧迫。

标签: ios cordova camera phonegap-plugins


【解决方案1】:

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

  • www\
  • --index.html
  • --phonegap.js
  • --图片\
  • --css\
  • --js\
  • ...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-02
    相关资源
    最近更新 更多