http://trueman-developer.blogspot.com/2016/08/swift2uialertcontroller.html
1 2 3 4 5 6 7 8 9 | // 全面のviewContloller を取得する var tc = UIApplication.sharedApplication().keyWindow?.rootViewController; while ((tc!.presentedViewController) != nil) { tc = tc!.presentedViewController; } let alert = tc as ? UIAlertController if alert != nil { alert!.dismissViewControllerAnimated(false, completion: nil) } |
一番前面の画面がUIAlertControllerだったら閉じる。
completionで閉じたあとの挙動も定義できる模様。
複雑な画面操作が必要なときに使う。