此项目为您提供可以在任何 iOS 应用中插入的密码控件。它的行为与在设置>通用>密码锁定中可以看到的密码屏幕完全一致。
以下是快速的示例。要查看使用情况,请打开 "SampleApp" Xcode 项目。
GCPINViewController *PIN = [[GCPINViewController alloc]
initWithNibName:nil
bundle:nil
mode:GCPINViewControllerModeCreate];
PIN.messageText = @"Create Passcode";
PIN.errorText = @"The passcodes do not match";
PIN.verifyBlock = ^(NSString *code) {
NSLog(@"setting code: %@", code);
return YES;
};
[PIN presentFromViewController:self animated:YES];
[PIN release];
GCPINViewController *PIN = [[GCPINViewController alloc]
initWithNibName:nil
bundle:nil
mode:GCPINViewControllerModeVerify];
PIN.messageText = @"Check Passcode";
PIN.errorText = @"Incorrect passcode";
PIN.verifyBlock = ^(NSString *code) {
NSLog(@"checking code: %@", code);
return [code isEqualToString:@"0187"];
};
[PIN presentFromViewController:self animated:YES];
[PIN release];