The Uialertcontroller of new characteristics of iOS8

Source: Internet
Author: User

IOS8 combines many of the familiar controls.

For example, this sectionto: Uialertcontroller

Uialertcontroller combines all the features of the Uialert/uiactionsheet

Create code Uialertcontroller *alert = [Uialertcontroller alertcontrollerwithtitle:@ "hint" message:@ "ah ah ah ah ah" PreferredStyle: Uialertcontrollerstylealert];
<p class= "P2" ><span class= "S1" >//modal controller </span></p><p class= "P2" ><span class= "S1 ">[</span><span class=" S2 ">self</span><span class=" S1 "> </span> Presentviewcontroller<span class= "S1" >:alert </span>animated<span class= "S1" >:</span>< span class= "s2" >yes</span><span class= "S1" > </span>completion<span class= "S1" >:</ Span><span class= "S2" >nil</span><span class= "S1" >];</span></p>

Preferredstyle is an enumeration
<p class= "P1" ><span class= "S1" >typedef</span> <span class= "S1" >NS_ENUM</span> ( Nsinteger, Uialertcontrollerstyle) {</p><p class= "P1" > Uialertcontrollerstyleactionsheet = <span class = "S2" >0</span>,</p><p class= "P1" > Uialertcontrollerstylealert</p><p class= "P2" > <span class= "S3", </span>ns_enum_available_ios<span class= "S3" > (</span><span class= "s2 ">8</span><span class=" S3 ">_0);</span></p>


However, this bullets out of the box is not clicked button.

Therefore, you must add a button event

<pre name= "code" class= "OBJC" >        //Uialertactionstylecancel is a type enum//        typedef ns_enum (Nsinteger, Uialertactionstyle) {//            Uialertactionstyledefault = 0,//            uialertactionstylecancel,//            uialertactionstyledestructive//        } ns_enum_available_ios (8_0);

Uialertaction *action = [uialertaction actionwithtitle:@ "OK" style:uialertactionstylecancel handler:^ (UIAlertAction * Action) {        //callback inside block//To do.    }];    [Alert addaction:action];            Uialertaction *actiondelete = [uialertaction actionwithtitle:@ "Delete" Style:uialertactionstyledestructive handler:^ ( Uialertaction *action) {        //To do.    }];    [Alert Addaction:actiondelete];

The Add button is OK, but what do I do to add an input box?

class provides a way to:

-(void) Addtextfieldwithconfigurationhandler: (void (^) (Uitextfield *textfield)) Configurationhandler;

    [Alert addtextfieldwithconfigurationhandler:^ (Uitextfield *textfield) {        Textfield.placeholder = @ "one";    }];
can set TextField arbitrary properties in block, more flexible

@property (nonatomic, readonly) nsarray *textfields;//Get all the input boxes


I'll share it here today.


The Uialertcontroller of new characteristics of iOS8

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.