Uiactionsheet operation form-iOS development

Source: Internet
Author: User

What is an operation form? Figure:

You can see from the figure.

UIActionSheet* mySheet = [[UIActionSheet alloc]                           initWithTitle:@"ActionChoose"                            delegate:self                            cancelButtonTitle:@"Cancel"                           destructiveButtonTitle:@"Destroy"                           otherButtonTitles:@"OK", nil];    [mySheet showInView:self.view];

Similar to uialertview, we also process the actions after the button is pressed in the delegate method. Remember to add uiactionsheetdelegate to the delegate class.

- (void)actionSheetCancel:(UIActionSheet *)actionSheet{    //}- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{    //}-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{    //}-(void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex{    //}

Did you see the red button? It is a so-called destroy button supported by actionsheet, which plays a warning role on an action of a user,

For example, permanently delete a message or log. If you specify a destroy button, it will be highlighted in red:

mySheet.destructiveButtonIndex=1;

Similar to the navigation bar, the operation form also supports three styles:

Uiactionsheetstyledefault // default style: The white text uiactionsheetstyleblacktranslucent is displayed on the gray background // The transparent black background, the white text uiactionsheetstyleblackopaque // The pure black background, and the white text

Usage example:

Mysheet. actionsheetstyle = uiactionsheetstyleblackopaque;

There are three methods to display actionsheet:

1. display in a view. You can use showinview

[Mysheet showinview: Self];

2. To align actonsheet with the toolbar or label bar, you can use showfromtoolbar or showfromtabbar.

[Mysheet showfromtoolbar: toolbar];

[Mysheet showfromtabbar: tabbar];
Release Operation form

After you press the button, the actionsheet will disappear-unless the application has a special reason, You need to press a button. The dismiss method can be used to make the form disappear:

[mySheet dismissWithClickButtonIndex:1 animated:YES];


Related Article

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.