1.UIAlertVIew in-(void) Show method displays:
-(void) viewdidload { [super viewdidload]; Use of Uialertview [self showalert]; Uiacyionsheet use// [self showaction]; #pragma mark [self showalertcontroller]; The method cannot be placed here because Uialertcontrol inherits from the use of Uiviewcontroller//uialertcontrol [self showalertcontroller]; }
Implementation of Uialertview:
-(void) showalert{ uialertview *alertview = [[Uialertview alloc]initwithtitle:@ "Emergency notice" message:@ "due to the happiness index Oh falling, After investigation and vacation into a linear relationship, special approval after work one day rest day "delegate:self cancelbuttontitle:@" Cancel "otherbuttontitles:@" OK ", nil]; Alertview.alertviewstyle = Uialertviewstyledefault; /* Uialertviewstyledefault, default uialertviewstylesecuretextinput, password input box uialertviewstyleplaintextinput , text input box uialertviewstyleloginandpasswordinput user and password */ [Alertview show];} #pragma mark-uialertdelegate-(void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (Nsinteger) ButtonIndex { switch (buttonindex) {case 0: NSLog (@ "Click%ld", Buttonindex); break; Case 1: NSLog (@ "Click%ld", Buttonindex); break; Default: Break ; }}
Use of 2.UIActionSheet
-(void) showaction{ uiactionsheet *actionsheet = [[Uiactionsheet alloc]initwithtitle:@ ' leave \ Select leave type ' delegate:self cancelbuttontitle:@ "Cancel" destructivebuttontitle:@ "Leave" otherbuttontitles:@ "sick Leave" @ "maternity leave", nil]; [Actionsheet ShowInView:self.view];} -(void) didreceivememorywarning { [super didreceivememorywarning]; Dispose of any resources the can be recreated.} #pragma mark uiactionsheetdelegate-(void) Actionsheet: (Uiactionsheet *) Actionsheet Clickedbuttonatindex: (NSInteger) buttonindex{ Switch (buttonindex) {case 0: NSLog (@ "Click%ld", Buttonindex); break; Case 1: NSLog (@ "Click%ld", Buttonindex); break; Case 2: NSLog (@ "Click%ld", Buttonindex); break; Default: Break ; }}
Simple use of 3.UIAlertControl
-(void) showalertcontroller{//uialertcontrollerstyle Two types of uialertcontrollerstylealert similar to Uialertview// Uialertcontrollerstyleactionsheet similar to uiactionsheet uialertcontroller *alertcontrol = [UIAlertController alertcontrollerwithtitle:@ "You and Me" message:@ "Together Forever" preferredstyle:uialertcontrollerstylealert]; Block code blocks replace delegate uialertaction *actionone = [uialertaction actionwithtitle:@ "No Matter of Life and death" Style:ui Alertactionstyledestructive handler:^ (uialertaction *action) {NSLog (@ "dependency"); }]; Uialertaction *alerttwo = [uialertaction actionwithtitle:@ "Share weal and Woe" Style:uialertactionstyledefault handler : ^ (uialertaction *action) {NSLog (@ "thick and thin"); }]; Uialertaction *alertthree = [uialertaction actionwithtitle:@ "Sure" Style:uialertactionstylecancel handler:^ ( Uialertaction *action) {NSLog (@ "OK"); }]; [Alertcontrol Addaction:actionone]; [Alertcontrol Addaction:alerttwo]; [Alertcontrol Addaction:alertthree]; The Uialertcontrollerstyle type Uialertcontrollerstylealert can be added addtextfieldwithconfigurationhandler:^ (UITextField * TextField) [Alertcontrol addtextfieldwithconfigurationhandler:^ (Uitextfield *textfield) {textfield.text = @ "for Love "; }]; [Self Presentviewcontroller:alertcontrol animated:yes completion:nil]; }
Comparison of the use of Uialertcontrol with Uialertview and Uiactionsheet