当单击按钮时,我添加了face 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")
}
}
错误消息是:
[动画] [uiview setAnimationSenabled:]从一个 背景线程。从背景线程执行任何操作 在Uiview或子类不受支持,可能导致意外 和阴险的行为。
evaluatePolicy
的回调在背景队列中运行,所以做
DisptachQueue.main.async {
self.performSegue(withIdentifier: "MyProfile", sender: nil)
}