Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 在应用程序通过面部id和触摸id身份验证后,实例化EviewController问题_Swift_Xcode_Swift4_Xcode10 - Fatal编程技术网

Swift 在应用程序通过面部id和触摸id身份验证后,实例化EviewController问题

Swift 在应用程序通过面部id和触摸id身份验证后,实例化EviewController问题,swift,xcode,swift4,xcode10,Swift,Xcode,Swift4,Xcode10,我在页面中添加了一个“触摸id或面部id”按钮。我已为此按钮创建了一个操作:btnTouchIdOrFaceIdIsPressed。问题1:单击触摸id或面部id按钮后,它不会打开应用程序屏幕中的HomePageViewController。为什么? @IBAction func btnTouchIdOrFaceIdIsPressed(_ sender: UIButton) { self.useBiometricAuthentication() } func useBiometricA

我在页面中添加了一个“触摸id或面部id”按钮。我已为此按钮创建了一个操作:
btnTouchIdOrFaceIdIsPressed
。问题1:单击
触摸id或面部
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吗

问题1:它不会在应用程序中打开HomePageViewController 点击触摸id或面部id按钮后的屏幕。为什么?

@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)
    }
}
您可以检查navigationController是否为非零

print(navigationController ?? "NavigationController is nil")
问题2:你能为这个范围写一个解释吗?触摸id或人脸身份验证失败,对吗

触摸ID或面部ID身份验证失败

问题3:你能为这个范围写一个解释吗?“设备不支持面部id或触摸id”,对吗


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

请检查它是否进入
成功
状态,即调用
呼叫成功后登录操作
。如果是这样,请检查您的
导航控制器
是否为空,然后在成功登录操作后将打印输入CallMea。我看到印刷品了。但我已经用另一种方法解决了。我创建了一个函数。我在这个函数中写了performsgue。然后我在CallMeafterSuccessLoginAction中的DispatchQueue.main.async中调用了这个函数。成功了。我看到主页视图控制器。谢谢你的回复。如果可能的话,你能解释一下范围2和范围3吗?(问题2和问题3)或者你能说我的评论是正确的吗?还是失踪@Arnabore和亲爱的@Arnabore您能写下如何检查navigationController是否为零吗。你能分享这些代码吗?这可能是因为你当前的ViewController可能是以模式显示的。在这种情况下,关闭ViewController,然后从导航控制器中推送。或者移动到根导航控制器,然后推到HomeViewController。另一种方法是显示HomeController,但我想这不是您想要的