【发布时间】: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