接連查看我打得四處TouchID了一下,我有以下問題:加載成功TouchID登錄
成功TouchID登錄後,我該如何提出一個新的視圖控制器?
在viewController.m的代碼是:
#import "ViewController.h"
@import LocalAuthentication;
#import "SVProgressHUD.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
LAContext *context = [[LAContext alloc] init];
NSError *error;
// check if the policy can be evaluated
if (![context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error])
{
NSLog(@"error:%@", error);
NSString *msg = [NSString stringWithFormat:@"Can't evaluate policy! %@", error.localizedDescription];
[SVProgressHUD showErrorWithStatus:msg];
return;
}
// evaluate
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:@"Please login through TouchID"
reply:
^(BOOL success, NSError *authenticationError) {
dispatch_async(dispatch_get_main_queue(), ^{
if (success) {
[SVProgressHUD showSuccessWithStatus:@"Everything Worked!"];
//Code for new viewController should come here!
}
else {
NSLog(@"error:%@", authenticationError);
[SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"FAILED! %@", authenticationError.localizedDescription]];
}
});
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
viewController.h是非標準。沒有什麼改變。 感謝支持:)