问题描述
我想知道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:
-
applicationDidBecomeActive
- 。 。你的应用程序所做的其他事情
- 你的应用程序会调用Touch ID,它会触发:
-
applicationWillResignActive
applicationDidBecomeActive
- ..other stuff your app does
- Your app invokes Touch ID, which fires:
applicationWillResignActive
-
applicationDidBecomeActive
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!