当用户离开并重新进入应用程序而不杀死它时,保持警报视图处于活动状态

时间:2017-04-08 19:59:31

标签: ios swift alertview

我有一个警报视图,当用户按下注销按钮时,他们可以选择注销或取消,但是如果我离开应用程序并返回(不会杀死应用程序)警报,则警报视图处于活动状态视图消失,但我希望它仍然处于活动状态,因为用户尚未选择取消或注销。有没有办法实现这个目标?感谢

嗯我没想到在这种情况下我的代码是必要的,无论如何这里我的功能看起来像什么

func displayLogOutAlert() {
    let alert = PCLBlurEffectAlert.Controller(title: nil, message: nil, effect: UIBlurEffect(style: .light), style: .actionSheet)
    let alertBtnYes = PCLBlurEffectAlert.Action(title: "Log Out", style: .destructive, handler: { (action) in
        alert.dismiss(animated: true, completion: nil)
        FBSDKLoginManager().logOut()
        GIDSignIn.sharedInstance().signOut()
        self.logoutIndicator.startAnimating()
        self.performSegue(withIdentifier: "backToLogin", sender: self)
        })
    let alertBtnCancel = PCLBlurEffectAlert.Action(title: "Cancel", style: .cancel, handler: nil)
        //self.presentingViewController?.dismiss(animated: true, completion: nil)
    alert.addAction(alertBtnYes)
    alert.addAction(alertBtnCancel)

    //setting button/text properties
    alert.configure(cornerRadius: 10)
    alert.configure(buttonBackgroundColor: UIColor.white)
    alert.configure(buttonHeight: 55)
    alert.configure(buttonFont: [.destructive: UIFont.systemFont(ofSize: 20), .cancel: UIFont.boldSystemFont(ofSize: 20)])
    alert.show()


}

1 个答案:

答案 0 :(得分:0)

使用 iOS状态恢复概念来实现此目标。

当你去吃午餐并在桌面上留下东西时,你会发现返回后一切都会保留。当用户按下iPhone上的“主页”按钮或接听电话时,您的用户期望相同。他希望打开应用程序并在相同的状态下找到应用程序,就像它留下的那样。

开发人员经常跳过应用程序状态保留。为了让用户满意,我们必须关心应用程序状态保存和恢复。

enter image description here

以下是link实施