rootViewController не отображается (Xcode 11 и iOS 13) - PullRequest
0 голосов
/ 24 октября 2019

Я пытаюсь установить rootViewController в iOS 13.0 и Xcode 11.0, но первый раз root корректно устанавливается из класса SceneDelegate, но после этого я пытаюсь установить root, и ничего не происходит.

let networkAlert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
static let appDelegate   = UIApplication.shared.delegate as! AppDelegate
let windowScene = UIApplication.shared.connectedScenes.filter { $0.activationState == .foregroundActive }.first

if let windowScene = windowScene as? UIWindowScene {
    appDelegate.window = UIWindow(windowScene: windowScene)           
    appDelegate.window?.frame = UIScreen.main.bounds
    appDelegate.window?.backgroundColor = .clear
    appDelegate.window?.windowLevel = UIWindow.Level.alert 
    appDelegate.window?.rootViewController?.isModalInPresentation  = true
    appDelegate.window?.rootViewController?.modalPresentationStyle = .fullScreen
    appDelegate.window?.rootViewController?.present(networkAlert!, animated: true, completion: nil)
    appDelegate.window?.makeKeyAndVisible()
}

Также пробовал с этим, но объект SceneDelegate недоступен, он будет работать только во время запуска приложения:

let timeline = TimelineViewController()
let navigation = UINavigationController(rootViewController: timeline)
let frame = UIScreen.main.bounds
window = UIWindow(frame: frame)
window!.rootViewController = navigation
window!.makeKeyAndVisible()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...