Example:
Uialertview *alertview = [[Uialertview alloc] initwithtitle:@ "Default Alert View" message:@ "Defalut" delegate:self cancelbuttontitle:@ "Cancel" otherbuttontitles:@ "OK", nil];
Standard Double button, cancel that Buttonindex is 0, OK button's Buttonindex is 1
Uialertview *alertview = [[Uialertview alloc] initwithtitle:@ "Default Alert View" message:@ "Defalut" delegate:self cancelbuttontitle:@ "Cancel" otherbuttontitles:@ "OK" @ "Thirdbutton", nil];
In the same order as in the program, the Buttonindex of the cancel OK Thirdbutton is 0 1 2, respectively.
Uialertview *alertview = [[Uialertview alloc] initwithtitle:@ "Default Alert View" message:@ "Defalut" delegate:self cancelbuttontitle:@ "Cancel" otherbuttontitles:@ "OK" @ "Thirdbutton", nil];
Similarly, the buttonindex of the cancel OK Thirdbutton Fourthbutton is 0 1 2 3 respectively.
[Alertview show];
Uialertview Delegate
-(void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (nsinteger) Buttonindexalertview---> You don't have to say that anymore. Buttonindex----> from 0 can be controlled by the if (Buttonindex = = 1) {} to control what needs to be done by clicking on a button -(void) Alertview: (Uialertview *) Alertview Diddismisswithbuttonindex: (Nsinteger) Buttonindex This method calls -(void) Alertview after the end of the animation and the View is hidden: ( Uialertview *) Alertview Willdismisswithbuttonindex: (Nsinteger) Buttonindex This method calls -before the animation starts and the view is hidden (void) Alertviewcancel: (Uialertview *) Alertview before the view is going to be canceled for example, the user clicks on the home key three functions call order: Alertviewcancel----" Willdismisswithbuttonindex---"diddismisswithbuttonindex -(BOOL) Alertviewshouldenablefirstotherbutton ( Uialertview *) Alertviewios 5+ settings yes/no will set Alertview's first Otherbutton's Enable property -(void) Didpresentalertview :(Uialertview *) Alertview call - (void) Willpresentalertview after the view is submitted to the User: (Uialertview *) Alertview the order in which the view was submitted to the user before the call The six delegate method calls is Alertviewshouldenablefirstotherbutton----> Willpresentalertview--->didpresentalertview---->clickedbuttOnatindex----> (call Alertviewcancel If a view cancellation is triggered) Willdismisswithbuttonindex---->diddismisswithbuttonindex ios4.0 later Alertview does not automatically remove the Alertview property as the program turns to the background 1.alertviewstyle:uialertviewstyledefault Only the message and button Uialertviewstylesecuretextinput has a TextField encryption box Uialertviewstyleplaintextinput There is an unencrypted textfielduialertviewstyleloginandpasswordinput with two textfield,login and password As long as there is TextField can be used Textfieldatindex to capture and do the appropriate action such as the keyboard type 2.cancelbuttonindex start is 0, if you do not set the Cancel button is -1 3. Delegate if not set is Nil 4.firstotherbuttonindex starting from 0, if not set is-1, and is not set will be ignored 5.message message 6. NumberOfButtons the number of buttons in a read-only alertview 7.title title 8.visible read-only If yes means Show instance Method-(Nsinteger) Addbuttonwithtitle: (NSString *) Title return value is the increment of the button's index -(NSString *) Buttontitleatindex: (Nsinteger) Buttonindex input Buttonindex Returns the caption of the button -(void) Dismisswithclickedbuttonindex: (Nsinteger) Buttonindex animated: ( BOOL) Animated program automatically completes clicking on the Buttonindex button and dismiss the entire Alertview operation -(ID) initwitHtitle: (NSString *) title message: (nsstring) message delegate: (ID) Delegate Cancelbuttontitle: (NSString *) Cancelbuttontitle otherbuttontitle: (NSString *) Otherbuttontitles, ... That's not going to be a lot of talk. -(void) show to show that the Alertview must be called before - (Uitextfield *) Textfieldatindex: (Nsinteger) Textfieldindex return value is Textfielduialertviewstyledefault no uialertviewstylesecureinput textfieldindex Only one for 0UIAlertViewStylePlainInput Textfieldindex only one for 0UIAlertViewStyleLoginAndPasswordInput Textfieldindex has two X 0 1
Uialertview Use full solution