0
我遇到了在本地身份驗證中更改視圖控制器的問題。當所有的代碼在成功的if語句中執行時,即使我告訴它,視圖控制器也不會改變。我試過了解我所知道的一切,但沒有成功。這是我的本地認證碼。本地身份驗證不會更改視圖控制器
let authentication = LAContext()
var authenticationError: NSError?
authentication.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &authenticationError)
if (authenticationError != nil) {
// Authentication Not available for this version of iOS
self.gotoMainViewController()
} else {
authentication.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: "Access Passy using Touch ID") {
(success, error) in
if (error != nil) {
// There was an error - user likley pressed cancel
print(error?.localizedDescription)
} else {
if (success) {
dispatch_async(dispatch_get_main_queue()) {
self.gotoMainViewController()
}
} else {
self.showFailedTouchIDError.showAlert()
}
}
}
}
這裏是gotoMainViewController()代碼。
func gotoMainViewController() {
let viewController = MainViewController()
self.navigationController?.pushViewController(viewController, animated: true)
}
發佈你的'gotoMainViewController()'方法代碼 –
我已經更新了問題以包含代碼gotoMainViewController方法 –