小编use*_*085的帖子

如何使用Swift使用TouchID?

Apple为iOS 8的TouchID实现提供的文档在Objective-C中.

有Swift版本吗?

Objective-C的:

- (IBAction)touchIDAvailable:(UIButton *)touchIDAvailableButton {
    LAContext *context = [[LAContext alloc] init];
    __block  NSString *msg;
    [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:NSLocalizedString(@"Place your finger on the sensor", nil) reply: ^(BOOL success, NSError *authenticationError) {
         if (success) {
         }
    }
}
Run Code Online (Sandbox Code Playgroud)

迅速:

@IBAction func touchidbutton(sender: AnyObject) {
    authContext.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: "Place your finger on the sensor"?, reply: ((success : Bool, NSError!) -> Void)?){
        if (success) {
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

objective-c ios swift ios8

5
推荐指数
2
解决办法
8640
查看次数

标签 统计

ios ×1

ios8 ×1

objective-c ×1

swift ×1