【问题标题】:How to navigate to another page when faceId identified?识别出faceId后如何导航到另一个页面?
【发布时间】:2019-05-25 17:11:05
【问题描述】:

当点击按钮时,我添加了人脸识别和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 或子类上,可能会导致意外 和阴险的行为。

【问题讨论】:

    标签: ios swift face-id


    【解决方案1】:

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

    DisptachQueue.main.async {
      self.performSegue(withIdentifier: "MyProfile", sender: nil)
    }
    

    【讨论】:

      猜你喜欢
      • 2021-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多