【问题标题】:instantiateViewController problem after the app passes the face id and the touch id authentication应用通过face id和touch id认证后instantiateViewController问题
【发布时间】:2019-03-12 11:48:19
【问题描述】:

我在我的页面中添加了一个“touch id 或 face id”按钮。我为此按钮创建了一个操作:btnTouchIdOrFaceIdIsPressed。问题1:点击touch id or face id 按钮后,应用程序屏幕中没有打开HomePageViewController。为什么?

@IBAction func btnTouchIdOrFaceIdIsPressed(_ sender: UIButton) {
    self.useBiometricAuthentication()
}

func useBiometricAuthentication () {
    let context = LAContext()
    var error : NSError?
    let reason = "some message for app user for the touch id or face id.."
    if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
        context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { (success, error) in
            if success {
                self.callMeAfterSuccessLoginAction()
            } else {
                //Question2: Can you write an explanation for this scope? Touch id or face is authentication is failed, right?
            }
        }
    } else {
        //Question3: Can you write an explanation for this scope? "device does not support face id or touch id", right?
    }
}

func callMeAfterSuccessLoginAction() {
    DispatchQueue.main.async {
        let oHomepageViewController = self.storyboard?.instantiateViewController(withIdentifier: "Homepage") as! HomepageViewController
        self.navigationController?.setViewControllers([oHomepageViewController], animated: true)
    }
}

你也可以回答问题2和问题3吗?

【问题讨论】:

  • 请检查它是否进入success 条件,即callMeAfterSuccessLoginAction 被调用。如果是这样,请检查您的 navigationController 是否不为零
  • 我将 print 放入 callMeAfterSucessLoginAction。我看到印刷品。但我已经用另一种方式解决了。我创建了一个函数。我在这个函数中写了 performegue。然后我在 callMeAfterSucessLoginAction 的 DispatchQueue.main.async 中调用了这个函数。有效。我看到主页视图控制器。谢谢回复。如果可能的话,你能解释一下Scope2和Scope 3吗? (问题2和问题3)或者你能说我的cmets是正确的吗?或失踪? @ArnabHore
  • 亲爱的@ArnabHore 你能写我如何检查navigationController 不是零。可以分享一下代码吗?
  • 这可能是因为您当前的 ViewController 可能会以模态方式呈现。在这种情况下,关闭 ViewController,然后从导航控制器推送。或者移动到根导航控制器,然后推送到 HomeViewController。
  • 另一种方式是呈现 HomeController,但我猜这不是你想要的

标签: swift xcode swift4 xcode10


【解决方案1】:

问题1:在app里没有打开HomePageViewController 单击触摸 ID 或面部 ID 按钮后的屏幕。为什么?

你可以检查你的navigationController是否不为零

print(navigationController ?? "NavigationController is nil")

问题2:你能解释一下这个范围吗? Touch id 或 face 是身份验证失败,对吧?

Touch ID 或 Face ID 身份验证失败

问题3:你能解释一下这个范围吗? “设备不支持 face id 或 touch id”,对吧?

Touch ID 或 FaceID 验证不可用,可能是用户未设置

【讨论】:

    猜你喜欢
    • 2023-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-18
    • 2022-11-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多