-1

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

好吧,我认为在这种情况下不需要放置我的代码,无论如何这就是我的函数的样子

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()


}
4

1 回答 1

0

使用iOS 状态恢复概念来实现这一点。

当你去吃午饭并在桌子上留下一些东西时,你期望在你回来后一切都会保持原样。当用户按下 iPhone 上的“主页”按钮或接听电话时,他的期望也是一样的。他希望打开应用程序并找到处于与离开时相同状态的应用程序。

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

在此处输入图像描述

这是实现的链接

于 2017-04-08T20:10:24.070 回答