Touch ID指纹识别功能 iOS8
2015-12-20 13:56
531 查看
- (IBAction)loginAction:(id)sender { NSLog(@"登录触发方法"); // 步骤一 检查Touch ID是否可用 LAContext *myContext = [[LAContext alloc] init]; NSError *authError = nil; NSString *myLocalizedReasonString = @"通过Home键验证已有手机指纹"; if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) { NSLog(@"Touch ID可以使用"); [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:myLocalizedReasonString reply:^(BOOL success, NSError * _Nullable error) { if (success) { // 成功 NSLog(@"成功"); UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; SuccessViewController *successVC = [storyboard instantiateViewControllerWithIdentifier:@"SuccessViewController"]; [self.navigationController pushViewController:successVC animated:YES]; } else { // 获取到相应的错误信息····做相应的操作 // 失败 NSLog(@"%@", error); // 错误信息 NSString *domin = [error domain]; //获取错误域 一般 NSLog(@"%@", domin); NSDictionary *userInfo = [error userInfo]; //错误详细信息 NSLog(@"%@", userInfo); NSInteger code = [error code]; // 获取Code值 一般domin 和 code 一起就是一个错误信息 if (code == -3) { // 点击了手指密码的 输入密码按钮 NSLog(@"点击了手指密码的 输入密码按钮"); } if (code == -2) { NSLog(@"点击了手指密码的取消按钮"); } if (code == -1) { NSLog(@"指纹密码不可用, 重新输入指纹密码"); } } }]; }else { // NSLog(@"Touch ID 不可用"); } }
demo下载地址:
http://download.csdn.net/detail/yj229201093/9369022
参考链接
/article/2260271.html
相关文章推荐
- iOS中播放音乐和音效
- 映泰主板BIOS刷入slic并激活
- iOS_ScrollView的自己主动布局
- iOS新版本特性(引导页)
- BIOS相关
- iOS 基础类解析 - NSCharacterSet___开发中判断空字符串的几种方法
- 收集了1000个iOS 常用的库
- 94个iOS开发资源推荐,帮你加速应用开发
- iOS屏幕尺寸和分辨率了解
- ios7上文字上半部分字体缺失
- iOS 中 CAShapeLayer 的使用( 等待删除的博文)
- iOS之Target
- iOS开发:多个按钮点击滑动效果
- iOS Default-568@2x.png启动图片设置问题
- iOS LBS
- iOS开发之蓝牙通讯
- iOS军火库-好用的ActionSheetView
- IOS开发之文本复制
- IOS 开发中相机获取图片 不同方向的相机获取不同的图片的实现 ||图片的从新绘图
- iOS学习:调用相机,选择图片上传,带预览功能