我已经用phonegap 2.2.0完成了我的项目。现在,我想更新我的项目2.2.0到3.4.0。因此,我使用cordova 3.4.0创建了一个新项目。我为这个项目添加了两个平台(ios, android)。我从我以前的项目中复制了html,css和javascript文件。我有三页的相机选项。所以,我安装了cordova相机插件使用以下注释cordova插件添加org.apache.cordova。camera但是,camera选项只能在一个页面上工作。那时候我也有以下错误在X-code控制台['Camera'] took '37.391357' ms.插件应该使用一个后台线程。
请指引我....
使用
(function($) {
var Core = window.Core || Core || {};
Core.upload = {
init: function (){
Core.upload.bindEvents();
},
bindEvents: function() {
$('#upload_photo').bind('click',function(e){
e.preventDefault();
Core.upload.photo.get(navigator.camera.PictureSourceType.PHOTOLIBRARY);
return false;
});
$('#upload_camera').bind('click',function(){
Core.upload.photo.capture();
return false;
});
},
photo: {
get: function(source) {
navigator.camera.getPicture(Core.upload.photo.onSuccess, Core.upload.photo.onFail,{
quality: 50,
sourceType: source,
});
},
capture: function capturePhoto() {
navigator.camera.getPicture(Core.upload.photo.onSuccess, Core.upload.photo.onFail, { quality: 50 });
},
onSuccess: function(imageData) {
appendImage(imageData);
},
onFail: function(message) {
navigator.notification.alert(message);
}
}
};
$(Core.upload.init);
window.Core = Core;
})(jQuery);
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.DATA_URL
});
function onSuccess(imageData) {
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
不要忘记更新新库并在构建中包含
我有同样的问题与相机插件,我已经使用mp-cordova-plugin-camera