Touch ID本地验证产生线程12:EXC错误

时间:2018-02-13 15:02:29

标签: ios swift localauthentication

目前,我有以下代码。

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

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

enter image description here

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

1 个答案:

答案 0 :(得分:1)

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

一起使用

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

if success {

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

}