Important: Uialertview is deprecated in IOS 8. (Note that uialertviewdelegate is also deprecated.) To create and manage alerts in IOS 8 and later, instead use Uialertcontroller with a preferredstyle ofuialertcontrollersty Lealert.
uialertview will report the following warning:
' Uialertview ' was deprecated on IOS 9.0:uialertview is deprecated. Use Uialertcontroller with a preferredstyle of Uialertcontrollerstylealert instead? ?
Alert Views: Alert views display a concise and informative alert message to the user.
uialertcontroller also replaces UIAlertView and uiactionsheet, the concept of alert is unified at the system level-in the form of modal or popover.
viewcontroller.swiftimport uikitclass viewcontroller: uiviewcontroller { override func viewdidload () { super.viewdidload () // do any additional setup after loading the view, typically from a nib. //Create a button let button = uibutton (Type: uibuttontype.custom) Initialize Uibutton button.frame = cgrectmake (50, 100,  150, 50) //Create a cgrect, set location and size Button.backgroundcolor = uicolor.greencolor () //Set background color button.settitle ("Click to Show Pop-up Window", forstate: uicontrolstate.normal) //set the title // Pass-Through Touch object (click event) button.addtarget (self, action: " buttonpressed: ", forcontrolevents: uicontrolevents.touchupinside) self.view.addsubview (Button) } // action func buttonpressed (Sender: uibutton) { showalertreset () } func showalertdefault () { let alertcontroller = uialertcontroller (title: "pop-up window title", message: "hello, This is the default style for Uialertcontroller", preferredstyle: Uialertcontrollerstyle.alert) let cancelaction = Uialertaction (title: "Cancel", style: uialertactionstyle.cancel, handler: nil) let okaction = uialertaction (title: "Good", Style: uialertactionstyle.default, handler: nil) let resetaction = uialertaction (title: "Reset", style: Uialertactionstyle.destructive, handler: nil) alertcontroller.addaction (resetaction) alertcontroller.addaction (cancelAction) alertcontroller.addaction (okaction) &nbSp; self.presentviewcontroller (Alertcontroller, animated: true, completion: nil) } func showalertreset () { let alertcontrol = uialertcontroller (title: " The title of the pop-up window ", message: " hello,showalertreset ", preferredstyle: Uialertcontrollerstyle.alert) let cancelaction = uialertaction (title: "Cancel operation", style: uialertactionstyle.destructive, handler: Nil) let okAction = Uialertaction (title: "good", style: uialertactionstyle.default, handler: nil) alertcontrol.addaction (cancelaction) alertcontrol.addaction (okaction) &nbsP; self.presentviewcontroller (alertcontrol, animated: true, Completion: nil) } override Func didreceivememorywarning () { Super.didreceivememorywarning () // Dispose of any resources that can be recreated. }}
Reference:
Http://www.jianshu.com/p/86f933850df8
http://blog.csdn.net/xiaowenwen1010/article/details/40108097
[Swift] Uikit Learning Warning Box: Uialertcontroller and Uialertview