iOS 개발 중 지문 인식 에 대한 간단 한 소개
그래서 우 리 는 지문 인식 애플 리 케 이 션 을 할 때 기종 과 시스템 버 전 을 판단 해 야 한다.
코드 는 다음 과 같 습 니 다.다음 에 특히 주의해 야 할 것 은 바로 LAPolicy DeviceOwner Authentication 과 LAPolicy DeviceOwner Authentication With Biometrics 의 차이 점 입 니 다.검 측 시스템 의 버 전 은[UIDevice currentDevice].systemVersion.floatValue 를 통 해 장치 가 Touch ID 를 사용 할 수 있 는 지 여 부 를 판단 하 는 것 은 canEvaluate Policy:error:이 방법 으로 판단 합 니 다.그리고 주의해 야 할 것 은 지문 인식 성공 여 부 를 검증 하 는 작업 은 기본적으로 하위 스 레 드 에서 진행 되 기 때문에 UI 작업 을 하려 면 메 인 스 레 드 로 돌아 가 실행 해 야 합 니 다.4
dispatch_async(dispatch_queue_t _Nonnull queue, ^{ })
이 함 수 를 이용 하여 실현 할 수 있 습 니 다.그 안에 홈 팀 열 에 들 어가 면 됩 니 다.그리고 저 희 는 eror 의 code 에 따라 사용자 가 구체 적 으로 어떤 원인 으로 인해 잘못 되 었 는 지 판단 한 다음 에 해당 하 는 출력 을 할 수 있 습 니 다.
//1、 8.0
if([UIDevice currentDevice].systemVersion.floatValue>=8.0)
{
// , 5S
// LA
LAContext * context = [[LAContext alloc]init];
//
//Evaluate
//Policy
// touchID
if([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil])
{
//LAPolicyDeviceOwnerAuthentication , , 。
touch ID , LAPolicyDeviceOwnerAuthenticationWithBiometrics
, , , , touch id
//
[context evaluatePolicy:LAPolicyDeviceOwnerAuthentication localizedReason:@" " reply:^
(BOOL success, NSError * _Nullable error) {
// , UI ,
//
if(success)
{
NSLog(@"%@",[NSThread currentThread]);
NSLog(@" ");
}
else
{
NSLog(@" ");
}
NSLog(@"%@",[NSThread currentThread]);
NSLog(@"%@",error);
if(error)
{
if(error.code==-2)
{
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController * vc = [UIAlertController alertControllerWithTitle:@" " message:@""
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * action = [UIAlertAction actionWithTitle:@" " style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"---------");
}];
UIAlertAction * action1 = [UIAlertAction actionWithTitle:@" " style:UIAlertActionStyleCancel
handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"hhhhhh");
}];
[vc addAction:action];
[vc addAction:action1];
[self presentViewController:vc animated:YES completion:nil];
});
}
else if(error.code==-1)
{
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController * vc = [UIAlertController alertControllerWithTitle:@" 3 " message:
@" " preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * action = [UIAlertAction actionWithTitle:@" " style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"---------");
}];
[vc addAction:action];
[self presentViewController:vc animated:YES completion:nil];
});
}
}
}];
}
}
else
{
NSLog(@" , ");
}
총결산위 에서 말 한 것 은 편집장 님 께 서 소개 해 주신 iOS 개발 에서 지문 인식 에 대한 간단 한 소개 입 니 다.여러분 께 도움 이 되 셨 으 면 좋 겠 습 니 다.궁금 한 점 이 있 으 시 면 메 시 지 를 남 겨 주세요.편집장 님 께 서 바로 답 해 드 리 겠 습 니 다.여기 서도 저희 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Swift의 패스트 패스Objective-C를 대체하기 위해 만들어졌지만 Xcode는 Objective-C 런타임 라이브러리를 사용하기 때문에 Swift와 함께 C, C++ 및 Objective-C를 컴파일할 수 있습니다. Xcode는 S...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.