ios - 如何在 iOS 应用程序中显示密码 View

标签 ios swift uiviewcontroller

我正在开发一个 iOS 项目,并且想要保护该应用程序的安全。我已经能够创建和密码 View Controller ,它工作正常,但我想在应用程序即将进入后台或进入前台之前显示密码 View 。我知道 Appdelegate 提供了有用的方法,但我如何实现它来显示密码 View Controller 。我尝试实现 rootviewcontroller 以在 Appdelegate 中显示密码 View Controller ,但它不起作用并给出调试器消息“尝试显示不在层次结构中的 View Controller ”。

最佳答案

将此行添加到 viewDidLoad() 函数中:

 NSNotificationCenter.defaultCenter().addObserver(self, selector: "showPasscodeView:", name: UIApplicationWillEnterForegroundNotification, object: nil)

然后在 showPasscodeView() 函数中显示密码 View 。

关于ios - 如何在 iOS 应用程序中显示密码 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41329773/

相关文章:

ios - 如何在 iOS 中为 UITextView 添加两个输入附件 View ?

ios - 有一种方法可以知道是否在 ios 中点击了标签栏按钮的 View ?

ios - SwiftUI View 未更新以反射(reflect) UIViewController 中的数据更改

iphone - 如何将多个自定义 View Controller 与导航 Controller 一起使用?

iphone - UITabBarController 是如何工作的?

ios - 需要从呈现的 UINavigationController 中返回到呈现的 UIViewController

swift - 无法将类型 'Promise<T>' 的值分配给类型 'Promise<_>?'

ios - Swift:手势识别器不注册点击

ios - (Swift, EarlGrey) 将 slider 移动到中间

ios - 关闭 2 个 ViewController