Uialertcontroller class--sheet Pull-up menu 1 (Basic)

Source: Internet
Author: User

First, the effect

Second, the Code implementation

-(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (Uievent *) event

{

[Self sheetTest1];

}

/**

Note: You cannot add a text box to the pull-down menu

If a text box is forcibly added, a run-time error is reported:

Reason: ' Text fields can-only is added to an alert controller of style Uialertcontrollerstylealert '

*/

/**

* Bottom pull-up menu

*/

-(void) SheetTest1

{

/**

The pull-up menu can be useful when you need to show users a range of choices, and the pull-up menu is displayed in the form of a device size.

1. On iphone (tighten width), pull-up menu rises from bottom of screen

2. On ipad (regular width), the pull-up menu is displayed as a popup box

The way you create a pull-down menu is very similar to the way you create a dialog box, except that the only difference is their form

*/

/**

Note: the "Cancel" button is always at the bottom of the pull-down menu

The IOS user interface Guide requires that all "destroy" style buttons must be ranked first and red.

*/

1. Create a View Controller

Uialertcontroller *alertcontroller = [Uialertcontroller

alertcontrollerwithtitle:@ "Save or delete data"

message:@ "Delete data will not be recoverable"

Preferredstyle:uialertcontrollerstyleactionsheet];

2. Add a button

Uialertaction *cancelaction = [uialertaction

actionwithtitle:@ "Cancel"

Style:uialertactionstylecancel

Handler:nil];

Uialertaction *deleteaction = [uialertaction

actionwithtitle:@ "Delete"

Style:uialertactionstyledestructive

Handler:nil];

Uialertaction *archiveaction = [uialertaction

actionwithtitle:@ "Save"

Style:uialertactionstyledefault

Handler:nil];

3. Add a button to the view controller

[Alertcontroller addaction:cancelaction];

[Alertcontroller addaction:deleteaction];

[Alertcontroller addaction:archiveaction];

4. Display View Controller

[Self Presentviewcontroller:alertcontroller animated:yes completion:nil];

}

Uialertcontroller class--sheet Pull-up menu 1 (Basic)

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.