如何在识别出 faceId 后导航到另一个页面?
How to navigate to another page when faceId identified?
点击按钮时我添加了人脸识别和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:] being called from a
background thread. Performing any operation from a background thread
on UIView or a subclass is not supported and may result in unexpected
and insidious behavior.
evaluatePolicy
的回调在后台队列中运行
DisptachQueue.main.async {
self.performSegue(withIdentifier: "MyProfile", sender: nil)
}
点击按钮时我添加了人脸识别和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:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior.
evaluatePolicy
的回调在后台队列中运行
DisptachQueue.main.async {
self.performSegue(withIdentifier: "MyProfile", sender: nil)
}