Я не могу понять, как получить окно оповещения в Spritekit. Этот код ниже работал, но KeyWindow устарел, так что мне теперь делать?
let currentViewController : UIViewController=UIApplication.shared.keyWindow!.rootViewController!
Я пробовал:
let currentViewController : UIViewController = (self.view?.window!.rootViewController)!
любые другие варианты, но, похоже, ни один из них не подходит Работа. Предупреждение просто не появится.
Может кто-нибудь пролить немного света на эту проблему?
полный кодовый блок:
let ac = UIAlertController(title: "Connect to others", message: nil, preferredStyle: .actionSheet)
ac.addAction(UIAlertAction(title: "Host a session", style: .default, handler: startHosting))
ac.addAction(UIAlertAction(title: "Join a session", style: .default, handler: joinSession))
ac.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
let currentViewController :
UIViewController = (self.view?.window!.rootViewController)!
currentViewController.present(ac, animated: true, completion: nil)