问题描述
使用cordova 2.8.1我试图做一个camera.getPicture与图片库。它似乎是工作的Android,但不是为iOS。下面是我如何调用getPicture的代码。在一个iPhone 4s与iOS 6它允许我选择一个图像,但一旦这样做的错误回调被调用与参数为null
Using cordova 2.8.1 I am trying to do a camera.getPicture with photolibrary. It seems to be working for android but not for iOS. below is how I call the getPicture code. On an iPhone 4s with iOS 6 it allows me to select an image, but as soon as thats done the error callback is called with the argument being null
var options = {
quality : 30,
destinationType : Camera.DestinationType.FILE_URI,
sourceType : Camera.PictureSourceType.PHOTOLIBRARY,
correctOrientation: true,
targetWidth: 800,
targetHeight: 800
};
navigator.camera.getPicture(this.captureSuccessPre, this.captureError, options);
我被告知要在console.logs周围添加一个超时。在phonegaps文档它说明这样做周围的警报。下面是我的错误回调。其中日志[错误null]
I was told to add a timeout around the console.logs. On phonegaps documentation it states to do so around alerts. Below is my error callback. which logs [error null]
captureError: function(error){
setTimeout(function(){
console.log("error " + error); //logs error null
}, 100);
}
任何人都有任何想法。我一直在努力几天。如果它有助于任何此代码与
Anyone have any ideas. I have been struggling for a few days. If it helps any this code works perfect with
sourceType : Camera.PictureSourceType.CAMERA,
推荐答案
似乎与DestinationType.FILE_URI有关。
I have exactly the same problem; seems to be related to the DestinationType.FILE_URI.
试试这个:
var options = {
quality : 30,
destinationType: navigator.camera.DestinationType.NATIVE_URI,
sourceType : Camera.PictureSourceType.PHOTOLIBRARY,
correctOrientation: true,
targetWidth: 800,
targetHeight: 800
};
这篇关于Cordova 2.8.1:camera.getPicture与ios上的photolibarary源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!