美文网首页
Swift 警告显示最佳实践

Swift 警告显示最佳实践

作者: 张嘉夫 | 来源:发表于2016-08-26 13:46 被阅读99次

我为 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)
  }

}

相关文章

网友评论

      本文标题:Swift 警告显示最佳实践

      本文链接:https://www.haomeiwen.com/subject/cpczsttx.html