How to use Uiactionsheet in iOS
First, the method of initialization
-(instancetype) Initwithtitle: (nsstring *) title delegate: (ID< Uiactionsheetdelegate>) Delegate cancelbuttontitle: (nsstring *) cancelbuttontitle Destructivebuttontitle: (nsstring *) destructivebuttontitle otherbuttontitles: (nsstring *) Otherbuttontitles, ...;
Parameter description:
Title: View Title
Delegate: Setting up the agent
Cancelbuttontitle: The title of the Cancel button
Destructivebuttontitle: Title of the Special tagged button
Otherbuttontitles: Title of other buttons
Introduction of common methods and properties
@property(nonatomic,copy) nsstring *title;
Set Title
@property (nonatomic) Uiactionsheetstyle Actionsheetstyle;
To set the style, enumerate the following:
typedef ns_enum (Nsinteger, uiactionsheetstyle) {uiactionsheetstyleautomatic =-1, Uiactionsheetstylede Fault = uibarstyledefault, uiactionsheetstyleblacktranslucent = uibarstyleblacktranslucent, UIActionSheetSt Yleblackopaque = Uibarstyleblackopaque,};
-(Nsinteger) Addbuttonwithtitle: (nsstring *) title;
Add a button that returns the index of the button
-(nsstring *) Buttontitleatindex: (nsinteger) Buttonindex;
Get button title
@property(nonatomic,readonly) nsinteger numberofbuttons;
Get the number of buttons
@property (nonatomic) Nsinteger Cancelbuttonindex;
Set the index value of the Cancel button
@property (nonatomic) Nsinteger Destructivebuttonindex;
Set Special tags
@property(nonatomic,readonly,getter=isvisible) BOOL visible;
Whether the view is currently visible
Here are a few pop-up methods that show different ways depending on style
-(void) Showfromtoolbar: (uitoolbar *) view;
-(void) Showfromtabbar: (uitabbar *) view;
-(void) Showfrombarbuttonitem: (uibarbuttonitem *) Item animated: (BOOL) animated;
-(void) Showfromrect: (cgrect) rect inview: (UIView *) View animated: (BOOL) Animated;
-(void) Showinview: (UIView *) view;
-(void) Dismisswithclickedbuttonindex: (nsinteger) buttonindex animated: (BOOL) animated;
Use code to retract a view
Three, Uiactionsheet agent method
-(void) Actionsheet: (uiactionsheet *) actionsheet clickedbuttonatindex: (nsinteger) Buttonindex;
How to trigger when a button is clicked
-(void) Willpresentactionsheet: (uiactionsheet *) Actionsheet;
The method that fires when the view is about to pop up
-(void) Didpresentactionsheet: (uiactionsheet *) Actionsheet;
How the view has been triggered by pop-up
-(void) Actionsheet: (uiactionsheet *) actionsheet willdismisswithbuttonindex: (nsinteger ) Buttonindex;
The method that fires when the view is retracted when the button is clicked
-(void) Actionsheet: (uiactionsheet *) actionsheet diddismisswithbuttonindex: (nsinteger) Buttonindex;
Method triggered when the view has been retracted when the button is clicked
Uiactionsheet use in iOS