ios - Displaying an alert on a new View Controller -
i have button sends me on view controller. trying display alert on next view controller.
in viewdidload()
method of new controller, create new uialertcontroller
, display following
let alertcontroller = uialertcontroller(title: "default style", message: "a standard alert.", preferredstyle: .alert) let cancelaction = uialertaction(title: "cancel", style: .cancel) { (action) in // ... } alertcontroller.addaction(cancelaction) let okaction = uialertaction(title: "ok", style: .default) { (action) in // ... } alertcontroller.addaction(okaction) self.presentviewcontroller(alertcontroller, animated: true) { // ... }
note example taken nshipster website offers nice articles ios. can find article uialertcontroller here. explain other stuff can class, display action sheet example.
Comments
Post a Comment