通过使用phonegap和XCode,我开发了一款适用于iPad的iOS应用程序。通过在XCode 4.3中使用phonegap 1.3.0.js,我已经完成了ipad相册中的图像捕捉相机和图像选择。
主要问题是我已将X Code版本更新为X Code 5.1.1并在我的MAC MINI中安装了手机间隙2.9.1版本。但是当我在ipad2中测试应用程序时,图像捕获和图像选择不起作用。对X-Code的电话缺口不熟悉我无法确定它发生的问题。现在我正在使用内置于手机间隙2.9.1的cordova .js。
JavaScript函数正在调用语法
navigator.camera. get Picture();
来自该行。
我使用的代码如下
var imageLength = 0;
function take Picture() {
navigator.camera.get Picture()
};
你可以帮我解决一下。
答案 0 :(得分:0)
尝试这个
var pictureSource; // picture source
var destinationType; // sets the format of returned value
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
pictureSource = navigator.camera.PictureSourceType;
destinationType = navigator.camera.DestinationType;
}
// Called when a photo is successfully retrieved
//
function onPhotoDataSuccess(imageURI) {
alert("fire");
// Uncomment to view the base64-encoded image data
console.log(imageURI);
// Get image handle
//
var cameraImage = document.getElementById('image');
// Unhide image elements
//
cameraImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
cameraImage.src = imageURI;
}
// Called when a photo is successfully retrieved
//
function onPhotoURISuccess(imageURI) {
alert("fire");
// Uncomment to view the image file URI
console.log(imageURI);
// Get image handle
//
var galleryImage = document.getElementById('image');
// Unhide image elements
//
galleryImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
galleryImage.src = imageURI;
}
// A button will call this function
//
function capturePhoto() {
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
quality: 30,
targetWidth: 600,
targetHeight: 600,
destinationType: destinationType.FILE_URI,
saveToPhotoAlbum: true
});
}
// A button will call this function
//
function getPhoto(source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, {
quality: 30,
targetWidth: 600,
targetHeight: 600,
destinationType: destinationType.FILE_URI,
sourceType: source
});
}
// Called if something bad happens.
//
function onFail(message) {
//alert('Failed because: ' + message);
}
您可以在此处下载我的示例代码:https://github.com/datomnurdin/com.revivalx.cordova.camera