日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

添加指纹识别功能

發布時間:2025/3/15 编程问答 52 豆豆
生活随笔 收集整理的這篇文章主要介紹了 添加指纹识别功能 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

iPhone 5S開始硬件支持指紋識別功能,在iOS 8以后支持指紋識別,今天隨意試了試指紋識別功能的識別,寫了一個小demo

1.環境

引入頭文件

#import <LocalAuthentication/LocalAuthentication.h>

  

2.創建兩個頁面

第一個頁面添加一個button,用來觸發指紋識別的功能

第二個頁面就加個label//

// ViewController.m // FingerPrint // // Created by Silence on 16/1/22. // Copyright (c) 2016年 Silence. All rights reserved. //#import "ViewController.h" #import "SecondViewController.h" #import <LocalAuthentication/LocalAuthentication.h>@interface ViewController () {LAContext * _context; } @end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view, typically from a nib. }- (IBAction)buttonDidClick:(id)sender {_context = [[LAContext alloc]init];BOOL isSupport = [_context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil];if ([UIDevice currentDevice].systemVersion.floatValue < 8.0) {UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"當前系統版本不支持指紋識別" preferredStyle:UIAlertControllerStyleAlert];UIAlertAction * action = [UIAlertAction actionWithTitle:@"提示" style:UIAlertActionStyleDefault handler:nil];[alert addAction:action];[self presentViewController:alert animated:YES completion:nil];}else if (!isSupport){UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"當前設備不支持指紋識別" preferredStyle:UIAlertControllerStyleAlert];UIAlertAction * action = [UIAlertAction actionWithTitle:@"提示" style:UIAlertActionStyleDefault handler:nil];[alert addAction:action];[self presentViewController:alert animated:YES completion:nil];}else{[_context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"請按手印" reply:^(BOOL success, NSError *error) {if(success){
          //這部分處理驗證成功的邏輯SecondViewController * se = [[SecondViewController alloc]init];[self presentViewController:se animated:YES completion:nil];
            }}];}}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated. }@end

  

指紋識別功能的初步集成還是比較簡單的。

?

轉載于:https://www.cnblogs.com/easyfly/p/5151699.html

總結

以上是生活随笔為你收集整理的添加指纹识别功能的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。