Uialertview is used in the code, because there is no intelligent hint, the compilation is not a problem, but when triggered, it crashes, and there is no
Any hint, do not know what is wrong, if you encounter the same situation, we know how to solve.
An extension is written here, which makes it easier to use
[OBJC] View plain copy print? import foundation import uikit Extension uialertcontroller { class func showalert ( presentController: UIViewController!, title: String!, message: String!, cancelbuttontitle: string? = "Cancel", okbuttontitle: string? = "OK") { let alert = uialertcontroller (title: title!, message: message!, preferredstyle: Uialertcontrollerstyle.alert) if cancelbuttontitle { Alert.addaction (Uialertaction (Title: cancelbuttontitle!, style: uialertactionstyle.default, handler: nil))// do not handle cancel, just dismiss } if okButtonTitle { Alert.addaction (Uialertaction (title: okbuttontitle!, style: uialertactionstyle.default, Handler: nil))// do not handle cancel, just dismiss } presentcontroller!. Presentviewcontroller (alert, animated: true, completion: nil) } class func showalert ( presentController: UIViewController!, title: string!, message: String!, cancelButtonTitle: String? = "Cancel", okButtonTitle: String? = "OK", okHandler: ((uialertaction!) -> void)!) { let alert = uialertcontroller (title: title!, message: message!, preferredstyle: UialertcontrollersTyle. Alert) if cancelbuttontitle { alert.addaction (Uialertaction (title: cancelbuttontitle!, style: Uialertactionstyle.default, handler: nil))// do not handle cancel, just dismiss } if okButtonTitle { Alert.addaction (Uialertaction (title: okbuttontitle!, style: uialertactionstyle.default, Handler: okhandler))// do not handle cancel, just dismiss } presentcontroller!. Presentviewcontroller (alert, animated: