我正在使用phonegap相机插件。
我想知道是否有选项或方法让“选择相机或photoalbum”对话框出现,而不是严格只是当前可用的相册或相机选项。
navigator.camera.getPicture(gotPic, onFail, {
quality: 10,
destinationType: navigator.camera.DestinationType.DATA_URL,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 300
});
答案 0 :(得分:2)
从文档中试试
HTML
<button onclick="capturePhoto();">Capture Photo</button> <br>
<button onclick="getPhoto();">From Photo Library</button>
JS
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
function capturePhoto() {
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
destinationType: destinationType.DATA_URL });
}
function getPhoto() {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: pictureSource.PHOTOLIBRARY});
}
现在您可以在对话框或弹出窗口中使用这些按钮为用户提供两个不同的选项
P&gt; S:别忘了给成功和失败的回调函数