ios - PhoneGap 相机无法在 ios 10 上运行
<p><p>我有一个 onclick 类函数 getImage(); 的按钮当我在具有 ios 10 的 iphone 7 plus 上调用它时它崩溃了。有人可以告诉我为什么会发生这种情况并给我正确的代码来阻止它。这是我现在拥有的代码,这些代码过去可以在旧的 ios 和 android 上运行,现在仍然可以运行。</p>
<p>navigator.camera.getPicture 函数在 ios 10 设备上崩溃。</p>
<pre><code> function getImage() {
// Retrieve image file location from specified source
navigator.camera.getPicture(uploadPhoto,
function(message) {
alert('get picture failed');
}, {
quality: 80,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
correctOrientation : true,
allowEdit: true
}
);
}
function uploadPhoto(imageURI) {
//function sendPhoto(filetype){
var options = new FileUploadOptions();
options.fileKey="file";
//get file name
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
//Check if the device is android or not and if it is use the folowing code
var devicePlatform = device.platform;
if(devicePlatform == "Android"){
//check file extension
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1)+".jpeg";
}
var params = new Object();
params.value1 ="Babatunde";
params.value2 = "param";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(imageURI, "uploadUserPhoto.php", win, fail, options);
//Part of the commment out function sendPhoto
//}
}
function win(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
alert(r.response);
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您必须在 iOS 10 的 Info.plist 中添加此权限</p>
<blockquote>
<p>Camera :</p>
</blockquote>
<p>关键:隐私 - 相机使用说明<br/>
值(value):$(PRODUCT_NAME) 相机使用量</p>
<blockquote>
<p>Photo :</p>
</blockquote>
<p>Key : Privacy - Photo Library 使用说明<br/>
值(value):$(PRODUCT_NAME) 照片用途</p></p>
<p style="font-size: 20px;">关于ios - PhoneGap 相机无法在 ios 10 上运行,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/41177717/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/41177717/
</a>
</p>
页:
[1]