gpt4 book ai didi

ios - 如何快速关闭消息应用程序?

转载 作者:行者123 更新时间:2023-11-30 11:20:37 24 4
gpt4 key购买 nike

你能在这里看到吗:https://vimeo.com/279403383

我正在尝试显示密码 View 。因为这个应用程序对安全性很敏感。

因此,如果应用程序确实进入后台,则请求密码。

在这种情况下工作得很好。

但是,具体情况的工作方式很奇怪。

func applicationDidEnterBackground(_ application: UIApplication) {
guard let passcodeManageView = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "passcodeManageView") as? PasscodeManageViewController else { return }
passcodeManageView.state = State.loginMode
passcodeManageView.modalPresentationStyle = .overFullScreen

var rootViewController = UIApplication.shared.keyWindow?.rootViewController
while let presentController = rootViewController?.presentedViewController {
rootViewController = presentController
}
rootViewController?.present(passcodeManageView, animated: false, completion: nil)
}

所以,我的问题是

  1. 密码 View 如何覆盖MFMessageComposeViewController?

  2. 或者如何关闭 MFMessageComposeViewController?

最好的方法是什么???

最佳答案

您需要迭代应用程序中呈现的 ViewController 并将它们一一关闭。

func applicationDidEnterBackground(_ application: UIApplication) {  
if let rootViewController = UIApplication.shared.keyWindow?.rootViewController {
var presented = rootViewController.presentedViewController
while presented != nil
{
if presented is MFMessageComposeViewController {
rootViewController.dismiss(animated: false, completion: nil)
break
} else {
presented = presented?.presentedViewController
}
}

}

guard let passcodeManageView = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "passcodeManageView") as? PasscodeManageViewController else { return }
passcodeManageView.state = State.loginMode
passcodeManageView.modalPresentationStyle = .overFullScreen

var rootViewController = UIApplication.shared.keyWindow?.rootViewController
while let presentController = rootViewController?.presentedViewController {
rootViewController = presentController
}
rootViewController?.present(passcodeManageView, animated: false, completion: nil)

}

关于ios - 如何快速关闭消息应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51297534/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com