【发布时间】:2018-03-03 17:21:09
【问题描述】:
我有一个助手来显示我的警报
import UIKit
class AlertDialog {
class func showAlert(_ title: String, message: String, viewController: UIViewController) {
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
let OKAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alertController.addAction(OKAction)
let cancelAction = UIAlertAction(title: "Cancel", style: .default, handler: nil)
alertController.addAction(cancelAction)
viewController.present(alertController, animated: true, completion: nil)
}
}
如何管理视图控制器中的操作?
我是这样调用函数的;
AlertDialog.showAlert("Ok", message: "Some Message", viewController: self)
我需要获取处理程序选项。我应该将“handler: nil”改成什么?
【问题讨论】:
-
建议的副本是在视图控制器中使用 AlertAction,而不是使用单独的辅助类。
标签: ios swift handler uialertaction