2017-04-18 36 views
0

有什麼辦法可以選擇,如果用戶想要從相機拍攝照片或使用某些存儲的圖像專輯使用相同的選項從相機拍攝照片或使用存儲在相冊中的圖像使用相同的選項

例如,如果我使用此插件(https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-camera/index.html),則查看存儲圖像的選項將被禁用(請參閱圖像)。如何啓用該功能?

enter image description here

+0

的可能重複:[此](http://stackoverflow.com/questions/22450366/how-to-let-the-user-to-choose-from-gallery-or-take-picture- option-in-cordova?rq = 1)這也是[this]的重複(http://stackoverflow.com/questions/11852903/phonegap-give-user-option-of-picturesourcetype) –

回答

0

如果你使用這個插件。我會向用戶顯示一個對話框,詢問他們是否想使用圖庫或相機。

然後,您可以根據響應更改選項。例。

var source; 

if(response=="gallery"){ 

    source = Camera.PictureSourceType.PHOTOLIBRARY; 

} else { 

    source = Camera.PictureSourceType.CAMERA; 
} 

navigator.camera.getPicture(onSuccess, onFail, 
{ 
    sourceType: source 
}); 
相關問題