Comparison of the use of Uialertcontrol with Uialertview and Uiactionsheet

Source: Internet
Author: User

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

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.