Func ClickButton1 () {
Create Uialertcontroller
var alertctl: uialertcontroller = uialertcontroller(title: "Alert", message: "You clicked Button1", Preferredstyle: uialertcontrollerstyle. Alert)
Adding action to Uialertcontroller,action is a button action on Uialertcontroller, it is recommended to add at least one, if not added, Alertcontroller there is no corresponding button exit
var alertaction: uialertaction = uialertaction(title: "Action", Style: Uialertactionstyle. Default, Handler: {(param: uialertaction!), Void in
println("I am Alert Action")
var position = self. View. Center. X
})
Alertctl. addaction(alertaction)
Show Alert Controller
self. Presentviewcontroller(alertctl, animated: True, completion: nil)
/*var Alertview:uialertview = Uialertview (Frame:cgrect (Origin:cgpoint, x:50), y:200 (Size:cgsize, he ight:40 )))
Alertview.title = "Button1"
Alertview.message = "You clicked button1!"
Alertview.addbuttonwithtitle ("Confirm")
Alertview.delegate = Self
Alertview.show () */
}
"Swift" Uialertcontroller use