【发布时间】:2017-01-04 03:59:40
【问题描述】:
我正在开发一个可以拍照的应用程序,我正在使用 Cordova 学习。我用过这个js:
var takePhoto = function() {
navigator.camera.getPicture(onSuccess, onError, { quality: 30,
destinationType: Camera.destinationType.FILE_URI,
saveToPhotoAlbum: true,
targetWidth: 1500,
targetHeight: 1500
});
function onSuccess(imageData) {
$('.photoPreview').show();
var image = document.getElementById('photoSrc');
image.src = "data:image/jpeg;base64," + imageData;
photoData = imageData;
$('#photoMessage').html('');
}
function onError(message) {
}
}
每当我单击按钮时,它都不起作用,也没有任何反应。我用来选择现有照片的功能也是如此:
var selectPhoto = function() {
navigator.camera.getPicture(onSuccess, onFail, { quality: 30,
destinationType: Camera.destinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
targetWidth: 1500,
targetHeight: 1500
});
function onSuccess(imageData) {
$('.photoPreview').show();
var image = document.getElementById('photoSrc');
image.src = "data:image/jpeg;base64," + imageData;
photoData = imageData;
$('#photoMessage').html('');
}
function onFail(message) {
}
}
并添加我正在使用的信息
$('#selectPhoto').on('click', function() {
selectPhoto();
});
$('#takePhoto').on('click', function() {
takePhoto();
});
还有这个 HTML
<button id="selectPhoto" class="photo-button">Select Existing Photo</button>
<button id="takePhoto" class="photo-button">Take New Photo</button>
我正在使用最新的 Cordova 6.4.0、cordova-ios@4.3.1 和来自https://github.com/apache/cordova-plugin-camera 的最新 cordova-plugin-camera
请让我知道我应该做什么。谢谢!
【问题讨论】:
标签: ios cordova mobile cordova-plugins