extension UIViewController {
// 簡易なアラートダイアログを表示する
func showSimpleAlert(title: String?, message: String?, action: ((UIAlertAction) -> Void)? = nil) {
let alertController = UIAlertController(title: title,
message: message,
preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK",
style: .default,
handler: action)
alertController.addAction(defaultAction)
present(alertController, animated: true, completion: nil)
}
}
// 使い方例
self.showSimpleAlert(title: "hogehoge", message: "hello")
self.showSimpleAlert(title: nil, message: "hello", action: { _ in
self.navigationController?.popViewController(animated: true)
})
Last active
June 19, 2020 10:59
-
-
Save ochim/363ca39c682e2a7e8a245540babe8c35 to your computer and use it in GitHub Desktop.
[ios]簡易なアラートダイアログを表示する
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment