PhoneGap simple use on iOS: Pop-up dialogs and call camera

Source: Internet
Author: User

Popup dialog box

Use Navigator.notification.confirm () in PhoneGap to eject the native dialog box on iOS and get the click Index of the corresponding button, as follows:

navigator.notification.confirm(        msg,                 //要显示的信息        backFn,             //警告被忽略的回调函数        title,               //标题        btns||‘取消,确定‘           //按钮名称    )

The following encapsulation is done in the current project:

    showConfirm:function(msg,title,backFn,btns){    navigator.notification.confirm(        msg,                 //要显示的信息        backFn,             //警告被忽略的回调函数        title,               //标题        btns||‘取消,确定‘           //按钮名称    )}
Camera or album

Use Navigator.camera.getPicture () in PhoneGap to call the camera or album. The prototype is as follows:

    

The test code is as follows:

Showconfirm (msg, ' OK 1 ', function (button) {if (Button = = 1) {//zm__ Test call camera//camera.picturesourcetype .                          Camera Camera//camera.picturesourcetype.photolibrary Camera.PictureSourceType.SAVEDPHOTOALBUM album Navigator.        Camera.picturesourcetype = Camera.PictureSourceType.SAVEDPHOTOALBUM;                                                                Navigator.camera.getPicture (onsuccess, Onfail, {quality:50, DestinationType:destinationType.FILE_URI, Sourcetype:pi        Cturesource.savedphotoalbum});                        The successful callback function onsuccess (Imageuri) {console.log (Imageuri); }//Failed callback function onfail (message) {alert (' Failed becaus                         E: ' + message ');     }}//if statement end else {console.log ("click Cancel 3"); }}, (' OK 2, cancel 3 ');}

One sentence, MD edit code It's hard.

PhoneGap simple use on iOS: Pop-up dialogs and call camera

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.