[英]Get image from gallery iOS?
I created a factory to get image from gallery on iOS. 我创建了一个工厂来从iOS的图库中获取图像。 Now, I'm testing this factory on emulator(simulator) of iOS and it throws an exception.
现在,我正在iOS的模拟器(模拟器)上测试此工厂,它会引发异常。 How I haven't any iOS device to test I want know if this factory only works with device or if it's there a problem with this factory.
我没有任何要测试的iOS设备的方法,我想知道该工厂是否仅适用于该设备,或者该工厂是否存在问题。 On Android this factory works fine.
在Android上,该工厂正常运行。
factory 厂
var app = angular.module('starter');
app.factory('CameraFactory', ['$q', function($q) {
var options = {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: 0, // 0:Photo Library, 1=Camera, 2=Saved Photo Album
}
return {
getPicture: function(callback){
var onSuccess = function(imageData) {
window.resolveLocalFileSystemURL(imageData, function(fileEntry) {
if (callback) callback({
success:true,
path: fileEntry.nativeURL,
imageData: imageData
});
});
};
var onFail = function(e) {
console.log("onFail! " + e);
if (callback) callback( {success:false} );
};
navigator.camera.getPicture(onSuccess, onFail, options);
}
}
}]);
Exception 例外
1 706110 error Error: Can't find variable: Camera
http://192.225.162.87:8100/js/factories/CameraFactory.js:7:32
Line 7 has: Camera.DestinationType.FILE_URI
第7行具有:
Camera.DestinationType.FILE_URI
As @FernandoPaiva stated in the comments, The emulator does not support the API you are trying to access as it doesn't actually have a camera. 正如@FernandoPaiva在评论中所述,该模拟器不支持您尝试访问的API,因为它实际上没有相机。 You can see this noted in the documentation I have linked below.
您可以在下面链接的文档中看到这一点。
NOTE: The camera API only works on a real device, and not in the emulator.
http://ngcordova.com/docs/plugins/camera/ http://ngcordova.com/docs/plugins/camera/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.