【发布时间】:2018-09-08 02:52:21
【问题描述】:
我查看了几个关于 SO 的解决方案,但似乎都没有。我有一个问题,当我打开然后关闭一个应用程序时,它会连续“加载”两次。有没有办法或代码来阻止这种情况发生?该应用程序的配置方式是,当用户关闭然后打开应用程序时,App Delegate 中的代码将应用程序发送到“CommandandControlViewController”,该控制器决定用户是否已登录,未登录并发送到合适的视图控制器。
func applicationWillEnterForeground(_ application: UIApplication) {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.window = UIWindow(frame: UIScreen.main.bounds)
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let yourVC = mainStoryboard.instantiateViewController(withIdentifier: "CommandAndControlViewController") as! CommandAndControlViewController
appDelegate.window?.rootViewController = yourVC
appDelegate.window?.makeKeyAndVisible()
}
【问题讨论】:
标签: ios swift viewcontroller