present 元を変更する
Thank you for reading this post, don't forget to subscribe!let scenes = UIApplication.shared.connectedScenes
let windowScene = scenes.first as? UIWindowScene
guard let window = windowScene?.windows.first else { return nil }
window.rootViewController.rootViewController?.present(vc, animated: true, completion: nil)
古いプロジェクトでは
var baseView = UIApplication.shared.keyWindow?.rootViewController
while ((baseView?.presentedViewController) != nil) {
baseView = baseView?.presentedViewController
}
baseView?.present(alertController, animated: true, completion: nil)