iOS指纹识别的简单应用
指纹识别(TouchID)的简单应用,供大家参考,具体内容如下
1、调用
-(void)viewDidLoad{ [superviewDidLoad]; //Doanyadditionalsetupafterloadingtheview,typicallyfromanib. [selfsetupNotification]; UIButton*button=[[UIButtonalloc]initWithFrame:CGRectMake(100,100,100,100)]; [buttonsetTitle:@"点击调用"forState:UIControlStateNormal]; [buttonaddTarget:selfaction:@selector(actionDidClickButton:)forControlEvents:UIControlEventTouchUpInside]; [buttonsetTitleColor:[UIColororangeColor]forState:UIControlStateNormal]; [self.viewaddSubview:button]; } -(void)actionDidClickButton:(UIButton*)sender { [selftouchIDTest]; } -(void)touchIDTest { [TouchIDManagervalidateTouchID]; } -(void)setupNotification { [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(actionDidReceiveValidateTouchIDSuccess)name:ValidateTouchIDSuccessobject:nil]; [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(actionDidReceiveValidateTouchIDNotAvailable)name:ValidateTouchIDNotAvailableobject:nil]; [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(actionDidReceiveValidateTouchIDNotEnrolled)name:ValidateTouchIDNotEnrolledobject:nil]; [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(actionDidReceiveValidateTouchIDAuthenticationFailed)name:ValidateTouchIDAuthenticationFailedobject:nil]; [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(actionDidReceiveValidateTouchIDCancel)name:ValidateTouchIDCancelobject:nil]; [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(actionTouchIDLockout)name:ValidateTouchIDLockoutobject:nil]; } -(void)actionDidReceiveValidateTouchIDSuccess { NSLog(@"%s",__func__); } -(void)actionDidReceiveValidateTouchIDNotAvailable { NSLog(@"%s",__func__); } -(void)actionDidReceiveValidateTouchIDNotEnrolled { NSLog(@"%s",__func__); } -(void)actionDidReceiveValidateTouchIDAuthenticationFailed { NSLog(@"%s",__func__); } -(void)actionDidReceiveValidateTouchIDCancel { NSLog(@"%s",__func__); } -(void)actionTouchIDLockout { NSLog(@"%s",__func__); } -(void)dealloc { [[NSNotificationCenterdefaultCenter]removeObserver:self]; }
具体demo
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。