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,

After that, you'll do some simple apps. Nativejs some of the functions that are used frequently, so it's not difficult to do apps later.


The Age of Knowledge

With the face++ interface, a face-recognition app was made, and Microsoft's accuracy was almost as real.

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 not common on the iphone, the effect is seen in the top picture of the article,

MUI's Actionsheet are implemented in two ways. One or HTML5 imitation, one is to call the encapsulated Nativeui to implement,

As ever, it is better to recommend a native implementation. First, the effect is realistic, the second is less than the shortcomings.

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

To see, in fact, the Actionsheet method of invoking the Nativeui component, see: Here,

Above In fact, you just need to pass in a title, and a fixed cancel button. and the button array you need to pass in.

There is a callback function that infers e.index to determine which button was clicked,

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 "photo", One is "album",

Code:

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

When E.index=1, it was clicked on the first button "take a picture".

When the e.index=2. Click on the second button "albums".

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

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



Many other tutorials:

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

Many other study notes: Http://uikoo9.com/book

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.