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