iOS8指纹识别代码例子
来源:互联网 发布:java搜索引擎lucene 编辑:程序博客网 时间:2024/06/13 10:29
跟想象的一样,iOS 8中的指纹识别使用起来还是很方便的,只需要一个接口就能搞定,屏幕上弹出一个模态的框,跟app store上的一样。
直接上代码吧,下面代码拷贝自Apple的官方文档。
需要添加LocalAuthentication.framework库,注意只有真机才有这个库,模拟器没有
01.
#
import
"LocalAuthentication/LAContext.h"
02.
LAContext *myContext = [[LAContext alloc] init];
03.
NSError *authError = nil;
04.
NSString *myLocalizedReasonString = @
"请输入指纹"
;
05.
06.
if
([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
07.
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
08.
localizedReason:myLocalizedReasonString
09.
reply:^(BOOL success, NSError *error) {
10.
if
(success) {
11.
// User authenticated successfully, take appropriate action
12.
}
else
{
13.
// User did not authenticate successfully, look at error and take appropriate action
14.
}
15.
}];
16.
}
else
{
17.
// Could not evaluate policy; look at authError and present an appropriate message to user
18.
}
效果如图所示:MyAddressBook 是我的app名字,“请输入指纹”是代码中的字符串
还是很简单的。
0 0
- iOS8指纹识别代码例子
- ios8指纹识别
- iOS8指纹识别TouchID
- iOS8指纹识别TouchID
- iOS8指纹识别TouchID
- iOS8指纹识别TouchID
- iOS8指纹识别TouchID
- iOS8 指纹识别集成
- iOS8指纹识别TouchID开发
- ios8新特性之指纹识别
- Touch ID指纹识别功能 iOS8
- iOS8 以上的指纹识别开发
- iOS8 OCTouchID的简单使用 指纹识别
- Android 指纹识别代码
- 指纹识别
- 指纹识别
- 指纹识别
- 指纹识别
- Hibernate学习进阶
- Hbase 基本操作
- 如何解决 Sublime Text 3 不能正确显示中文的问题
- [Special] Design Pattern - Behavioral Patterns - Command Pattern
- 可拖动FPS显示框(UGUI)
- iOS8指纹识别代码例子
- linux新建进程--fork
- UVa 455 Periodic Strings
- java基础教程7:包
- java 第二章 理解面向对象
- android studio 需要虚拟化技术怎么破?
- Python Neurolab for neural network
- Caused by: java.sql.SQLException: The MySQL server is running with the --read-only option so it cann
- Part part = request.getPart("upfile"); 报错解决方法