【问题标题】:Touch ID Local Authentication produces Thread 12: EXC errorTouch ID 本地身份验证产生线程 12:EXC 错误
【发布时间】:2018-02-13 15:02:29
【问题描述】:

目前,我有以下代码。

if localAuthenticationContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) {
        
        localAuthenticationContext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reasonString) { success, evaluateError in
            
            if success {
                self.performSegue(withIdentifier: "settingChange", sender: self)                    //TODO: User authenticated successfully, take appropriate action

如果触摸 id 被正确验证,代码执行到另一个视图控制器,但是当我尝试代码时,我得到这个错误:

我在不使用 TouchID 的情况下尝试了代码,它工作正常,但我不知道为什么它在使用 TouchID 时会产生错误。有人可以帮忙吗?

【问题讨论】:

  • 控制台中有错误信息吗?像主线程的东西?因为performSegue()和UI相关,必须在主线程中完成。另外,上面写着evaluatePolicy() 状态:A closure that is executed when policy evaluation finishes. This is evaluated on a private queue internal to the framework in an unspecified threading context.

标签: ios swift localauthentication


【解决方案1】:

performSegue 操作可能存在问题。所有与 UI 更改相关的操作都必须在主队列中执行。将 DispatchQueue 与 main 一起使用。

试试这个看看(注意: 我在 Swift 4 中有解决方案):

if success {

  DispatchQueue.main.async(execute: {
     self.performSegue(withIdentifier: "settingChange", sender: self)
  })

}

【讨论】:

    猜你喜欢
    • 2023-01-26
    • 1970-01-01
    • 2017-05-10
    • 2012-09-30
    • 2021-05-24
    • 2021-10-30
    • 2015-03-24
    • 1970-01-01
    • 2020-08-27
    相关资源
    最近更新 更多