IOS8 new Features (1)--uialertcontroller

Source: Internet
Author: User

I. Introduction of IOS8

IOS8 new features, mainly on the UI is unified

1, Uialertcontroller 2, Uipresentaioncontroller: Manage all the controllers through modal (see note) 3, Uipopoverpresentationcontroller 4, Sizeclass + AutoLayout 5, app Extension app extension 6, Core Image (IOS 5 starts with, filter beauty 美图秀秀 type) II, Uialertcontroller 1, used in the past when we use the UIA Lertview and Uiactionsheet
1 //option Popup etc.2-(void) Alertviewold3 {4     Uialertview*alert = [[Uialertview alloc]initwithtitle:@"111"Message@"222" Delegate: Nil Cancelbuttontitle:@"Cancel"Otherbuttontitles:@"Determine", nil];5Alert.alertviewstyle = Uialertviewstyleloginandpasswordinput;//4 different ways6 [alert show];7     8     //If you want to listen to a click event, you need to set up the corresponding Proxy and act on the proxy method .9 }Ten  One //Bottom Popup A-(void) Aletsheetold - { -     Uiactionsheet*action = [[Uiactionsheet alloc]initwithtitle:@"111" Delegate: Nil Cancelbuttontitle:@"Cancel"Destructivebuttontitle:@"hesitate"Otherbuttontitles:@"Determine", nil]; the      - [Action ShowInView:self.view]; -}

2, and starting from iOS8, Uialertcontroller = Uialertview + uialertsheet

1 #pragmaMark--New IOS82 3-(void)New4 {5     //1. Create the middle popup: Uialertview6Uialertcontroller *alert = [Uialertcontroller alertcontrollerwithtitle:@"title"Message@"Popup Information"Preferredstyle:uialertcontrollerstylealert];7     8     //Create a popup at the bottom: Uialertsheet9     //Uialertcontroller *alert = [Uialertcontroller alertcontrollerwithtitle:@ "title" message:@ "pop-up Info" PreferredStyle: Uialertcontrollerstyleactionsheet];Ten      One     //2. Add a button (no proxy required) A      -     //there is a need to prevent circular references (you can inherit uialertcontroller by creating a new controller, printing information in dealloc, verifying that there is a final release) -__weaktypeof(alert) Weakalert =Alert; the[Alert addaction:[uialertaction Actionwithtitle:@"Determine"Style:uialertactionstyledestructive handler:^ (Uialertaction *action) { -          -NSLog (@"%@", [weakAlert.textFields.firstObject text]); -          +     }]]; -[Alert addaction:[uialertaction Actionwithtitle:@"Cancel"Style:uialertactionstylecancel Handler:nil]]; +[Alert addaction:[uialertaction Actionwithtitle:@"default"Style:uialertactionstyledefault Handler:nil]]; A      at     //3, add the text box (can only be added to the Uialertcontrollerstylealert style, if it is Preferredstyle:uialertcontrollerstyleactionsheet will crash)  -[Alert addtextfieldwithconfigurationhandler:^ (Uitextfield *TextField) { -          -Textfield.textcolor =[Uicolor Redcolor]; -Textfield.text =@"11111"; -          in         //listen to the text changes (if it is with the notice, remove the time to be aware of, click OK or cancel when you need to remove, more trouble) - [TextField addtarget:self Action: @selector (textfieldsvaluedidchange:) FORCONTROLEVENTS:UICONTROLEVENTEDITINGC Hanged]; to     }]; +[AlertAddtextfieldwithconfigurationhandler:^ (Uitextfield *TextField) { -          theTextfield.securetextentry =YES; *Textfield.text =@"22222"; $     }];Panax Notoginseng      -     //4, eject the controller, if you want to use modal the [self Presentviewcontroller:alert animated:yes completion:nil]; + } A  the-(void) Textfieldsvaluedidchange: (Uitextfield *) TextField + { -NSLog (@"%@", textfield.text); $}

3. The same way for iphone and ipad

1 #pragmaMark--New iOS8 in IPad2 /**3 * Note:4 Uialertcontrollerstyleactionsheet5 1. Cannot have text box6 2, in the ipad, must use the form of popover to show7  8 It's all in present .9  */Ten-(void) Newinpad One { A     //1, create the bottom of the popup: Uialertsheet -Uialertcontroller *alert = [Uialertcontroller alertcontrollerwithtitle:@"title"Message@"Popup Information"Preferredstyle:uialertcontrollerstyleactionsheet]; -      the     //1.1 This code can not write, because the default will be in the form of Uimodalpresentationpopover -Alert.Modalpresentationstyle=Uimodalpresentationpopover; -  -     //1.2 Set the PopOver pointing button (this code will be ignored in the iphone and will be implemented in the ipad) +Alert.Popoverpresentationcontroller. Barbuttonitem =Self.navigationItem.leftBarButtonItem; -      +     //2. Add a button (no proxy required) A      at     //there is a need to prevent circular references (you can inherit uialertcontroller by creating a new controller, printing information in dealloc, verifying that there is a final release) -__weaktypeof(alert) Weakalert =Alert; -[AlertAddaction: [Uialertaction Actionwithtitle:@"Determine"Style:uialertactionstyledestructive handler:^ (Uialertaction *action) { -          -NSLog (@"%@", [weakAlert.textFields.firstObject text]); -          in     }]]; -[Alert addaction:[uialertaction Actionwithtitle:@"Cancel"Style:uialertactionstylecancel Handler:nil]]; to[Alert addaction:[uialertaction Actionwithtitle:@"default"Style:uialertactionstyledefault Handler:nil]]; +      -     //4, eject the controller, if you want to use modal the [Self presentviewcontroller: Alert Animated:yes Completion:nil]; *}

Attention:

Uialertcontrollerstyleactionsheet

1. Cannot have text box

2, in the ipad, must use the form of popover to show

IOS8 new Features (1)--uialertcontroller

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.