Double Choice
//Instantiate Uialertcontrollervar av=uialertcontroller (title: "?? The ultimate big test???, ", Message:" You love Niu ma? ",PreferredStyle:UIAlertControllerStyle.Alert)//Instantiate the first option = Uialertaction ( Title: "Love", style:UIAlertActionStyle.Default) { (action:uialertaction!), Void in self.lbl1.text = "You choosed Love" //Callback set LBL1 text } //Instantiation of the second option = uialertaction (title: "Super Love", style: uialertactionstyle.destructive) { (action:uialertaction!), Void in self.lbl1.text= "You choosed Super Love " } //Add options to Dialog av.addaction (act1) av.addaction (ACT2) //Display dialog box Self.presentviewcontroller (AV, animated:true, Completion:nil)
text box input
var Alertcontroller=uialertcontroller (title: "Please Login", message: "Enter login Information",PreferredStyle:UIAlertControllerStyle.Alert) Alertcontroller.addtextfieldwithconfigurationhandler { (textfield:uitextfield!) -Void in Textfield.placeholder= "Login"} alertcontroller.addtextfieldwithconfigurationhandler {(textfield:uitextfield!), Voi D in Textfield.placeholder= "Password"Textfield.securetextentry=true} var okaction= uialertaction (title: "OK",Style:UIAlertActionStyle.Default) {(action:uialertaction!) -Void in var login=alertcontroller.textfields?. First as Uitextfield var password=alertcontroller.textfields?. Last as Uitextfield Self.lbl1.text=Login.text+password.text} var cancelaction= uialertaction (title: "Cancel", Style:UIAlertActionStyle.Default,handler:nil) alertcontroller.addaction (okaction) alertcontroller.addaction (cancelaction) Self.presentviewcontroller (Alertcontroller, Animated:true, Completion:nil)
Popup dialog Box Uialertcontroller