keyWindow
在ios 13中也被弃用,这使我为这个问题找到了另一个解决方案。
使用swift 5.1、ios 13和xcode 11的当前更新,下面的代码在使用时会创建“卡片视图”,这样用户可以轻松地向下滑动并返回到以前的视图。然而,问题是,如果用户在使用下面的代码时登录或注销,用户可以在注销后返回登录屏幕或主应用程序,这是有问题的。在故事板或未连接的视图控制器之间将用户分隔到不创建“卡片视图”的位置的最佳方法是什么?“变通解决方案”的问题是
关键窗口
已弃用。它在寻找官方解决方案的同时也起了作用。
在情节提要和未连接的视图控制器之间分隔的旧方法
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Start")
self.present(vc, animated: true, completion: nil)
解决方案
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "homeVC") as! UITabBarController
UIApplication.shared.keyWindow?.rootViewController = vc