LoginSignup
0
1

More than 5 years have passed since last update.

Swift アラートが出せない場合

Posted at

アラートが出せない場合

presentした後など、出せない場合のメモ

let alert = UIAlertController(title: "Error", message: "error message", preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(okAction)

var baseView = UIApplication.shared.keyWindow?.rootViewController
while ((baseView?.presentedViewController) != nil)  {
    baseView = baseView?.presentedViewController
}
baseView?.present(alertController, animated: true, completion: nil)
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1