关于iOS 3D touch 指纹验证的随笔
file:///Users/OWen/Desktop/3DTouch.png
隨著iOS系統(tǒng)不斷的更新迭代,蘋果總會推出一些新的功能,今天就研究了一下iOS8之后推出的指紋驗證的功能,然后寫了一個小demo,與君分享。。
上demo: ? 1:首先導入一個系統(tǒng)的庫文件 ? ? ?#import <LocalAuthentication/LocalAuthentication.h>
? ? ? ? ? ? ? ? ?2:
? ??LAContext *mycontent = [[LAContext alloc] init];
?? ?
? ? NSString *myLocalizedReasonString = @"小伙子,請輸入你的指紋";
? ? NSError *authError = nil;
?
? ? if ([mycontent canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
?? ? ? ?
? ? ? ? [mycontent evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
? ? ? ? ?
? ? ? ? ? ? ? ? ? localizedReason:myLocalizedReasonString
? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? reply:^(BOOL success, NSError *error) {
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (success) {
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // User authenticated successfully, take appropriate action
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } else {
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? NSLog(@"-----%@",error);
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // User did not authenticate successfully, look at error and take appropriate action
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? ? }];
?? ? ? ?
? ? } else {
? ? ? ? // Could not evaluate policy; look at authError and present an appropriate message to user
? ? }
?注意,測試神馬的還得在真機上調(diào)試。
轉(zhuǎn)載于:https://www.cnblogs.com/110-913-1025/p/5566353.html
總結(jié)
以上是生活随笔為你收集整理的关于iOS 3D touch 指纹验证的随笔的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [容易]中位数
- 下一篇: 在UltraEdit的查找和替换中使用正