我的应用程序中有一个登录系统。代码是这样的:
func showLoginView() {
if !isAuthenticated {
performSegue(withIdentifier: "loginView", sender: self)
}
}
@objc func appWillResignActive(_ notification : Notification) {
view.alpha = 0
isAuthenticated = true
showLoginView()
didReturnFromBackground = true
}
@objc func appDidBecomeActive(_ notification : Notification) {
if didReturnFromBackground{
showLoginView()
}
}
本质上,每当我退出应用程序时,这都会提示 loginView。但我只希望它在我退出应用程序时这样做。即,双击主页按钮并从内存中删除应用程序。如果我只是按下主页按钮,应用程序就会关闭,当我再次打开应用程序时,它不应该要求我登录。我将如何做到这一点?