Javascript 如何在xcode 5.1.1中使用phonegap-1.3.0.js实现摄像头功能
通过使用phonegap和XCode,我为iPad开发了一个iOS应用程序。通过使用phonegap 1.3.0.js和XCode 4.3,我已经完成了ipad相册中的摄像和图像选择 主要问题是我已经将X代码版本更新为X代码5.1.1,并在我的MAC MINI中安装了phone gap 2.9.1版本。但当我在ipad2中测试应用程序时,图像捕获和图像选择不起作用。由于不熟悉X代码的phone gap,我无法确定其发生的问题。现在我正在使用内置在phone gap 2.9.1中的cordova.js JavaScript函数正在调用,但语法Javascript 如何在xcode 5.1.1中使用phonegap-1.3.0.js实现摄像头功能,javascript,ios,xcode,cordova,Javascript,Ios,Xcode,Cordova,通过使用phonegap和XCode,我为iPad开发了一个iOS应用程序。通过使用phonegap 1.3.0.js和XCode 4.3,我已经完成了ipad相册中的摄像和图像选择 主要问题是我已经将X代码版本更新为X代码5.1.1,并在我的MAC MINI中安装了phone gap 2.9.1版本。但当我在ipad2中测试应用程序时,图像捕获和图像选择不起作用。由于不熟悉X代码的phone gap,我无法确定其发生的问题。现在我正在使用内置在phone gap 2.9.1中的cordova.
navigator.camera。获取图片()代码>从那一行开始
我使用的代码如下
var imageLength = 0;
function take Picture() {
navigator.camera.get Picture()
};
你能帮我修一下吗。试试这个
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);
}
您可以在这里下载我的示例代码:首先感谢您的回复。主要的问题是,当我调用它正在调用的javascript函数,但在navigator.camera.getPicture()处停止时。在那之后,我没有得到任何回应。我使用PhoneGap 2.9.1、codova 3.5.0 XCode 5.1.1作为参考。我已经将最新的cordova.js文件放在www文件夹中,index.html文件中给出了完美的路径。你能告诉我如何使用cordova.js for XCode 5.1.1和Phonegap 2.9.1Hi Mohammad吗?根据cordova 3.5.0版本,你能告诉我如何使用此功能吗