Javascript Phonegap-ios9文件输入 我有一个关于PosiGAP和iOS 9的问题,这对iOS 8来说很好,当你点击文件输入时,屏幕中间显示了一个取消按钮,在点击时什么都不做。文件输入在safari中可以正常工作,但在我的内置应用程序中却不行
我意识到有一个phonegap文件上传器API,但我使用我的应用程序作为我网站的移动版本的web浏览器,因此我还没有构建一个完全本地的应用程序,这对我来说是一个快速解决方案 这可能是因为新的操作表样式或ios 9中添加到操作表的新选项 是否有人有一个解决方案,我可以跳过行动表,当点击输入文件时,我直接进入摄像机镜头?或者对此进行任何修复?我移动到插件-这解决了问题 单击输入类型文件后:Javascript Phonegap-ios9文件输入 我有一个关于PosiGAP和iOS 9的问题,这对iOS 8来说很好,当你点击文件输入时,屏幕中间显示了一个取消按钮,在点击时什么都不做。文件输入在safari中可以正常工作,但在我的内置应用程序中却不行,javascript,ios,file,cordova,input,Javascript,Ios,File,Cordova,Input,我意识到有一个phonegap文件上传器API,但我使用我的应用程序作为我网站的移动版本的web浏览器,因此我还没有构建一个完全本地的应用程序,这对我来说是一个快速解决方案 这可能是因为新的操作表样式或ios 9中添加到操作表的新选项 是否有人有一个解决方案,我可以跳过行动表,当点击输入文件时,我直接进入摄像机镜头?或者对此进行任何修复?我移动到插件-这解决了问题 单击输入类型文件后: e.preventDefault(); navigator.notification.confirm
e.preventDefault();
navigator.notification.confirm(
'Please select image', // message
function (buttonIndex) {
if (buttonIndex === 1) {
photoFromSource(navigator.camera.PictureSourceType.CAMERA);
} else {
photoFromSource(navigator.camera.PictureSourceType.PHOTOLIBRARY);
}
}, // callback to invoke with index of button pressed
'Image capture', // title
['Camera', 'Gallery'] // buttonLabels
);
function photoFromSource(source) {
var targetWidth = 640,
targetHeight = 640,
onSuccess = function (imageURI) {
var image = new Image(),
canvas = document.createElement('canvas'),
canvasContext = canvas.getContext('2d');
image.onload = function () {
canvas.width = image.width;
canvas.height = image.height;
canvasContext.drawImage(image, 0, 0, image.width, image.height);
var dataURL = canvas.toDataURL();
self.model.set('imageData', dataURL);
self.model.setDataAttr('image', true);
self.render();
};
image.src = imageURI;
},
onFail = function (message) {
// Ignore if no image seleted
if (!/^no image selected$/.test(message))
alert('Failed because: ' + message);
},
opts = {
quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: source,
mediaType: navigator.camera.MediaType.PICTURE,
targetWidth: targetWidth,
targetHeight: targetHeight,
encodingType: navigator.camera.EncodingType.JPEG,
correctOrientation: true,
cameraDirection: navigator.camera.Direction.BACK,
saveToPhotoAlbum: false
};
try {
navigator.camera.getPicture(onSuccess, onFail, opts);
}
catch (e) {
alert('Could not capture image: ' + e);
}
};
我转向插件,这就解决了问题
单击输入类型文件后:
e.preventDefault();
navigator.notification.confirm(
'Please select image', // message
function (buttonIndex) {
if (buttonIndex === 1) {
photoFromSource(navigator.camera.PictureSourceType.CAMERA);
} else {
photoFromSource(navigator.camera.PictureSourceType.PHOTOLIBRARY);
}
}, // callback to invoke with index of button pressed
'Image capture', // title
['Camera', 'Gallery'] // buttonLabels
);
function photoFromSource(source) {
var targetWidth = 640,
targetHeight = 640,
onSuccess = function (imageURI) {
var image = new Image(),
canvas = document.createElement('canvas'),
canvasContext = canvas.getContext('2d');
image.onload = function () {
canvas.width = image.width;
canvas.height = image.height;
canvasContext.drawImage(image, 0, 0, image.width, image.height);
var dataURL = canvas.toDataURL();
self.model.set('imageData', dataURL);
self.model.setDataAttr('image', true);
self.render();
};
image.src = imageURI;
},
onFail = function (message) {
// Ignore if no image seleted
if (!/^no image selected$/.test(message))
alert('Failed because: ' + message);
},
opts = {
quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: source,
mediaType: navigator.camera.MediaType.PICTURE,
targetWidth: targetWidth,
targetHeight: targetHeight,
encodingType: navigator.camera.EncodingType.JPEG,
correctOrientation: true,
cameraDirection: navigator.camera.Direction.BACK,
saveToPhotoAlbum: false
};
try {
navigator.camera.getPicture(onSuccess, onFail, opts);
}
catch (e) {
alert('Could not capture image: ' + e);
}
};
您使用的是phonegap构建还是本地cordova开发?如果您使用cordova,您使用的是哪个xcode版本?您使用的是phonegap构建还是本地cordova开发?如果您使用cordova,您使用的是哪个xcode版本?