您的当前位置:首页正文

Swift 警告显示最佳实践

来源:图艺博知识网

我为 UIViewController 创建了一个 extension,在这里创建了一个 alert 函数:

extension UIViewController {

  func alert(message: String, title: String = "") {
    let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert)
    let OKAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
    alertController.addAction(OKAction)
    self.presentViewController(alertController, animated: true, completion: nil)
  }

}
Top