TouchID调用applicationWillResignActive和applicationDidBecomeActive [英] TouchID calls applicationWillResignActive and applicationDidBecomeActive

查看:184
本文介绍了TouchID调用applicationWillResignActive和applicationDidBecomeActive的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道Apple是否打算使用TouchID功能调用这些生命周期方法。

I am wondering if this is intended by Apple that these lifecycle methods are called upon using TouchID functionality.

是否有可能检查touchID进程是否正在调用这些方法(我想避免在app delegate中设置一个BOOL,如果当前显示的是touchID输入,则设置它。)

Is there any possibility to check if the touchID process is calling these methods (I want to avoid things like a BOOL in app delegate which is set if touchID input is currently shown or not..)

br

推荐答案

我猜你遇到的问题是你的代码是 applicationWillResignActive applicationDidBecomeActive 影响请求Touch ID验证的视图控制器,并且它会引发一个棘手的循环。

Im guessing the problem you're having is that you have code in applicationWillResignActive and applicationDidBecomeActive that affects the view controller that requests Touch ID-validation and that it sets off a tricky loop.

您需要做的是将这些调用移至 applicationDidEnterBackground applicationWillEnterForeground ,因为在调用Touch ID机制时不会调用它们。

What you need to do is move those calls to applicationDidEnterBackground and applicationWillEnterForeground, because they're not invoked when the Touch ID-mechanism is called.

要解释序列,当应用程序启动时,执行以下序列: / p>

To explain the sequence, when your app starts the following sequence executes:


  1. applicationDidBecomeActive

  2. 。 。你的应用程序所做的其他事情

  3. 你的应用程序会调用Touch ID,它会触发:

  4. applicationWillResignActive

  1. applicationDidBecomeActive
  2. ..other stuff your app does
  3. Your app invokes Touch ID, which fires:
  4. applicationWillResignActive




...您的应用程序被禁用,直到用户验证指纹(失败或
成功)...

... Your app is disabled until the user verifies fingerprint (fails or succeeds) ...




  1. applicationDidBecomeActive

  1. applicationDidBecomeActive

如果您的代码在 applicationDidBecomeActive - 或 - applicationWillResignActive 会影响Touch ID,你会创建一个无限循环或者更糟糕的是,你会创建充满标志和特殊情况的代码。

If you have code in applicationDidBecomeActive -or- applicationWillResignActive that affects Touch ID, you will create an endless loop or worse, you will create code that is riddled with flags and special cases.

相反,你应该在两种情况下调用Touch ID:

Instead you should invoke Touch ID in two cases:


  • 当你的应用程序启动时(通常在 didFinishLaunchingWithOptions

当你的应用程序的 applicationWillEnterForeground 被调用。

When your app's applicationWillEnterForeground is called.

这篇关于TouchID调用applicationWillResignActive和applicationDidBecomeActive的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆