Use of IOS UI Foundation -6.0 Uiactionsheet

Source: Internet
Author: User

Uiactionsheet is the Select button item that pops up in iOS, you can add multiple items and add click events for each item.

Use

1. Need to implement Uiactionsheetdelegate protocol

@interface Njwisdomcarddetailviewcontroller () <UIActionSheetDelegate>@end

2. Pop-Up selection button box

- (void) showsheet{Uiactionsheet*actionsheet =[[Uiactionsheet alloc] Initwithtitle:@"Title,nil when not displayed"                                  Delegate: Self cancelbuttontitle:@"Cancel"Destructivebuttontitle:@"Determine"Otherbuttontitles:@"First Item",@"Second Item", nil]; Actionsheet.actionsheetstyle=Uiactionsheetstyleblackopaque; [Actionsheet ShowInView:self.view];}

Parameter explanation:

    • Actionsheet. Actionsheetstyle = Uiactionsheetstyleblackopaque;//Set style
    • The Cancelbuttontitle and Destructivebuttontitle are the two buttons of the system belt.
    • Otherbuttontitles is a defined item, note that the last parameter is nil.
    • [Actionsheet Showinview: Self. View]; This line of statement means that the action sheet is displayed in the current view.

Style is set and the action form also supports three styles:

    • Uiactionsheetstyledefault // Default style: White text on gray background
    • Uiactionsheetstyleblacktranslucent // transparent black background, white text
    • Uiactionsheetstyleblackopaque // black background, white text

3. Listen for the item's click event. There are corresponding methods in implementing the Protocol.

(void) Actionsheet: (Uiactionsheet *) Actionsheet Clickedbuttonatindex: (nsinteger) buttonindex{if(Buttonindex = =0) {[Self Showalert:@"Determine"]; }Else if(Buttonindex = =1) {[Self Showalert:@"First Item"]; }Else if(Buttonindex = =2) {[Self Showalert:@"Second Item"]; }Else if(Buttonindex = =3) {[Self Showalert:@"Cancel"]; } }- (void) Actionsheetcancel: (Uiactionsheet *) actionsheet{}-(void) Actionsheet: (Uiactionsheet *) Actionsheet Diddismisswithbuttonindex: (Nsinteger) buttonindex{}-(void) Actionsheet: (Uiactionsheet *) Actionsheet Willdismisswithbuttonindex: (Nsinteger) buttonindex{}
Precautions

During the development process, it is found that sometimes the last click of the Uiactionsheet is invalidated, and the last item in the upper half of the point is valid, which happens only in certain circumstances, when the Uitabbar is tried . Workaround:

This is used in ShowView, [Actionsheet showinview:[uiapplication Sharedapplication].keywindow]; or [sheet showinview:[ Appdelegate Shareddelegate].tabbarcontroller.view]; So there will be no occlusion.

Use of IOS UI Foundation -6.0 Uiactionsheet

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.