也许有人可以提供帮助,只想使用 Segue 进行登录按钮,仅在使用 Touch ID 授权后才能传输到第二个 ViewController 但应用程序在用户按下按钮后仍执行 Segue。
import UIKit
import LocalAuthentication
class LoginWindowViewController: UIViewController {
@IBAction func loginButton(_ sender: Any) {
let context: LAContext = LAContext()
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil){
context.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, localizedReason: "For login you need to use your TouchID", reply: {(wasSuccessful, error) in if wasSuccessful {
DispatchQueue.main.async {
self.shouldPerformSegue(withIdentifier: "LoginComplete", sender: self.navigationController)
}
}else{
print ("Bad TouchID")
}
})
}
}
谢谢
最佳答案
尝试实现此函数并检查它的调用位置:
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
}
请记住,当您从代码中调用 Segue 时,如果您已经将 Segue 操作从按钮添加到 Storyboard 中的下一个 ViewController,则应将其删除,并仅在 LoginViewController 与您的 LoginViewController 之间创建连接。想打电话
关于swift - 如何仅在使用 Touch ID 授权后才执行 Segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47161533/