[英]take photo with camera or choose from gallery popover using phonegap
我正在使用phonegap相機插件。
我想知道是否有選項或方法彈出“從相機或相冊選擇”對話框,而不是僅顯示當前可用的相冊或相機選項。
navigator.camera.getPicture(gotPic, onFail, {
quality: 10,
destinationType: navigator.camera.DestinationType.DATA_URL,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 300
});
從文檔中嘗試
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> S:不要忘記給出成功和失敗的回調函數
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.