swift3にて、touchIdを使用して、認証をおこなう際、エラー時
パスコードを選択できるようになっています(以下コード参照)が、
パスコードを押してもパスコード入力画面が表示されません。
どうすれば、表示されるでしょうか。
import UIKit
import LocalAuthentication
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
} @IBAction func tap(_ sender: AnyObject) { startTouchID() } func startTouchID(){ let context = LAContext() var error :NSError? let localizedReason = "ホームボタンへ指を置いてください。" if context.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: &error){ context.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, localizedReason: localizedReason, reply: { success, error in if success { print("成功!!") self.showOKAlert() } else { print("失敗") } }) }else{ //TouchIDに対応していない場合 print("TourchIDに対応しておりません") } } func showOKAlert(){ let alertController = UIAlertController(title: "成功",message: "指紋認証に成功",preferredStyle: .alert) let okButton:UIAlertAction = UIAlertAction(title: "OK",style: UIAlertActionStyle.default,handler:{(action:UIAlertAction!) -> Void in let storyboard: UIStoryboard = self.storyboard! let nextView = storyboard.instantiateViewController(withIdentifier:"next") as! NextViewController self.present(nextView, animated: true, completion: nil) }) alertController.addAction(okButton) present(alertController, animated: true, completion:nil) }
コードは ``` で囲って下さい。
回答2件
あなたの回答
tips
プレビュー