如何使用iOS 8 指纹识别,代码、示例

像想象,iOS 8指纹是非常容易使用的。只是需要能够获得一个接口,弹出屏幕模式框,随着app store在相同的。

直接上的条形码。以下代码是从复制Apple官方文件。

加入LocalAuthentication.framework库,注意仅仅有真机才有这个库,模拟器没有

#import "LocalAuthentication/LAContext.h"
    LAContext *myContext = [[LAContext alloc] init];
    NSError *authError = nil;
    NSString *myLocalizedReasonString = @"请输入指纹";
    
    if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
        [myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
                  localizedReason:myLocalizedReasonString
                            reply:^(BOOL success, NSError *error) {
                                if (success) {
                                    // User authenticated successfully, take appropriate action
                                } else {
                                    // 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
    }


效果如图所看到的:MyAddressBook 是我的app名字。“请输入指纹”是代码中的字符串



还是很easy的。


版权声明:本文博主原创文章。博客,未经同意不得转载。

posted @ 2015-09-13 17:50  zfyouxi  阅读(192)  评论(0编辑  收藏  举报