Hbuilder Development App Combat-age 01-actionsheet instance

Source: Internet
Author: User
Tags nativeui

Objective

Previously wrote the Hbuilder Development app primer-drop Stone, I believe you should be able to get started after reading,

Then you will do some simple app, nativejs some of the common functions of all over again, so that after the app is no hard.


The Age of Knowledge

With the face++ interface, a face-recognition app was made, the accuracy and the Microsoft ratio were really nearly,

The main use of:

Native implementations of 1.actionsheet

2. Select a local photo

3. Use the camera to take pictures

4. Uploading Files using uploader

5. Call face++ interface for face recognition

6. Seven the implementation of the cow cloud upload


Actionsheet implementation

Actionsheet is very common on the iphone, the effect is seen in the top picture of the article,

MUI's Actionsheet has two implementations, one or HTML5, one is to invoke the encapsulated Nativeui for implementation,

As before, or a comparison of the implementation of the recommended native, one is the effect of realism, the second is less shortcomings.

Code:
Plus.nativeUI.actionSheet ({            title:title,            cancel: ' Cancel ',            buttons:btnarray        }, Function (e) {            if ( Func) func (e);        });

As you can see, the Actionsheet method that calls the Nativeui component is actually called, see: here,

As above, actually only need to pass in a title, and a fixed cancel button, as well as you need to pass in an array of buttons,

There is a callback function that determines which button is clicked by judging E.index.

Slightly encapsulated:
Actionsheetqiao.h.sheet = function (title, btns,func) {    if (title && btns && btns.length > 0) {
   var btnarray = [];        for (var i=0; i<btns.length; i++) {            Btnarray.push ({title:btns[i]});                Plus.nativeUI.actionSheet ({            title:title,            cancel: ' Cancel ',            buttons:btnarray        }, Function (e) {            if (func) func (e);        });}    ;
In this case,

The title is set to "select Photo", which requires two buttons, one is "take pictures", one is "album",

Code:

Qiao.h.sheet (' Select Photo ', [' Take Photos ', ' album '], function (e) {        var index = e.index;        if (index = = 1) choicecamera ();        if (index = = 2) choicepic ();    });

When the e.index=1, is clicked the first button "takes a picture",

When e.index=2, click on the second button "album",

When the e.index=0, click Cancel, do not do the processing,

When you click somewhere else, E.index=-1 does not do the same.



More Tutorials:

Hbuilder Development App Combat 1-age: HTTP://UIKOO9.COM/BOOK/DETAIL/5

More study notes: Http://uikoo9.com/book

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Hbuilder Development App Combat-age 01-actionsheet instance

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.