程序在ionic应用程序中的$cordovaCamera.getPicture函数的打开图像中退出
有人能告诉我我在代码中犯了什么错误吗?我调用cordova.getPicture函数,第一次打开应用程序,启动应用程序中的摄像头,然后单击应用程序自动终止,出现错误 但是当我第二次打开应用程序时,它是ok的,并显示在我的应用程序中,请帮助我程序在ionic应用程序中的$cordovaCamera.getPicture函数的打开图像中退出,camera,ionic,Camera,Ionic,有人能告诉我我在代码中犯了什么错误吗?我调用cordova.getPicture函数,第一次打开应用程序,启动应用程序中的摄像头,然后单击应用程序自动终止,出现错误 但是当我第二次打开应用程序时,它是ok的,并显示在我的应用程序中,请帮助我 $scope.browse_logo=function($event) { var uploadPopup = $ionicPopup.show({ title: "Upload Ad picture",
$scope.browse_logo=function($event) {
var uploadPopup = $ionicPopup.show({
title: "Upload Ad picture",
templateUrl: 'templates/explore1.html',
buttons: [
{
text: '',
type: 'button button-icon icon ion-ios-camera',
onTap: function(e) {
document.addEventListener("deviceready", function () {
var options = {
quality: 75,
destinationType: navigator.camera.DestinationType.DATA_URL,
sourceType: navigator.camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: 0,
targetWidth: 320,
targetHeight: 320,
// popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation:true
};
$cordovaCamera.getPicture(options).then(function(imageData) {
// var image = document.getElementById('myImage');
$scope.logoPhoto = imageData;
}, function(err) {
// error
});
}, false);
}
},
{
text: 'From gallery',
type: 'button button-positive',
onTap: function(e) {
// e.preventDefault();
// alert('Getting gallery');
$cordovaCamera.getPicture({
quality: 75,
targetWidth: 320,
targetHeight: 320,
allowEdit: true,
encodingType: 0,
destinationType: navigator.camera.DestinationType.DATA_URL,
sourceType: navigator.camera.PictureSourceType.SAVEDPHOTOALBUM
}).then(function(imageURI) {
//alert(imageURI);
$scope.logoPhoto = imageURI;
}, function(err) {
alert(err);
});
}
}
]
});
};
请尝试此功能,谢谢Mushin,但在添加图像时仍会退出程序。Xami mobile至少有一次无法正常工作。其余设备正常工作,但有时应用程序会突然关闭