0

当单击按钮时,我添加了人脸 id 识别,并且if true需要导航另一个页面。但不工作。应用程序崩溃。几分钟后导航到下一页,后退按钮不起作用。

 @IBAction func myProfile(_ sender: Any) {
    //    self.performSegue(withIdentifier: "MyProfile", sender: nil)
        let context:LAContext = LAContext()

        if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil){
            context.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, localizedReason: "Need to access with your finger print", reply: {(wasCorrect, error) in
                if wasCorrect{
                    print("correct")
                  self.performSegue(withIdentifier: "MyProfile", sender: nil)
                }else{
                print("incorrect")
                }
                })
        }else{
            print("finger print doesn't support touch id")
        }
    }

错误信息是:

[Animation] +[UIView setAnimationsEnabled:] 从后台线程调用。不支持从后台线程对 UIView 或子类执行任何操作,这可能会导致意外和隐蔽行为。

4

1 回答 1

1

回调evaluatePolicy后台队列中的运行,所以这样做

DisptachQueue.main.async {
  self.performSegue(withIdentifier: "MyProfile", sender: nil)
}
于 2019-05-25T17:14:54.940 回答