iOS Development-Uialertcontroller Bullet box Reminders

Source: Internet
Author: User

The traditional Alertview
- (void)alertView{    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"你的操作时非法的,您要继续吗" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定"nil];    alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;    [alert show];}

The traditional Actionsheet
- (void)actionSheet{    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"警告:你的操作时非法的,您要继续吗" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定"                                              otherButtonTitles:@"关闭"nil];    [sheet showInView:self.view]; }

Uialertcontroller = = Uialertview + uiactionsheet
- (void) alertcontroller{//Dangerous actions: Frame Reminders    //1.UIAlertView    //2.UIActionSheet    //iOS8 start: Uialertcontroller = = Uialertview + UiactionsheetUialertcontroller *alert = [Uialertcontroller alertcontrollerwithtitle:@"Warning"message:@"Your operation is illegal, do you want to continue?"Preferredstyle:uialertcontrollerstylealert];//Add button__Weaktypeof (Alert) Weakalert = alert; [Alert Addaction:[uialertaction actionwithtitle:@"OK"Style:uialertactionstyledestructive handler:^ (uialertaction *action) {NSLog(@"Clicked OK button--%@-%@", [Weakalert. Textfields. FirstobjectText], [Weakalert. Textfields. LastobjectText]);    }]]; [Alert Addaction:[uialertaction actionwithtitle:@"Cancel"Style:uialertactionstylecancel handler:^ (uialertaction *action) {NSLog(@"Click the Cancel button");    }]]; [Alert Addaction:[uialertaction actionwithtitle:@"Other"Style:uialertactionstyledefault handler:^ (uialertaction *action) {NSLog(@"Click on the other button"); }]];//Add text box[Alert addtextfieldwithconfigurationhandler:^ (Uitextfield *textfield) {TextField. TextColor= [UicolorRedcolor]; TextField. Text= @"123"; [TextField AddTarget: SelfAction@selector(Usernamedidchange:) forcontrolevents:uicontroleventeditingchanged];//[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (usernamedidchange:) name:uitextfie Ldtextdidchangenotification Object:textfield];}]; [Alert addtextfieldwithconfigurationhandler:^ (Uitextfield *textfield) {TextField. Securetextentry=YES; TextField. Text= @"123";    }]; [ SelfPresentviewcontroller:alert Animated:YESCompletion:Nil];} - (void) Usernamedidchange: (Uitextfield *) username{NSLog(@"%@", username. Text);}

Other operations
- (void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) Event {Uialertcontroller *alert = [Uialertcontroller alertControll erwithtitle:@"Warning"message:@"Your operation is illegal, do you want to continue?"Preferredstyle:uialertcontrollerstyleactionsheet];//Set PopOver point to itemAlert. Popoverpresentationcontroller. Barbuttonitem= Self. Navigationitem. Leftbarbuttonitem;//Add button[Alert Addaction:[uialertaction actionwithtitle:@"OK"Style:uialertactionstyledestructive handler:^ (uialertaction *action) {NSLog(@"Click OK button");    }]]; [Alert Addaction:[uialertaction actionwithtitle:@"Cancel"Style:uialertactionstylecancel handler:^ (uialertaction *action) {NSLog(@"Click the Cancel button");    }]]; [ SelfPresentviewcontroller:alert Animated:YESCompletion:Nil];}//Uialertcontrollerstyleactionsheet Use note//1. Cannot have a text box//2. In the ipad, you must use the form of popover to show//Text fields can is added to an alert controller of style Uialertcontrollerstylealert//Can only add text boxes on Uialertcontrollerstylealert-style view

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

iOS Development-Uialertcontroller Bullet box Reminders

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.