I have designed a small library (with its test project) that lets you implement a passcode lock screen on iOS. The library is compatible with iPod Touch, iPhone and iPad. And it is very easy to use.
EAPasscodeLock* passcodeManager = [[EAPasscodeLock alloc] init];
UIViewController* plViewController = [passcodeManager passcodeViewControllerWithCode:@"1234" cancellable:YES hintText:nil maxRetries:4 delegate:self];
[self presentModalViewController:plViewController animated:NO];
There is a protocol you should implement, with only one obligatory method, that sends messages to the main view.
@protocol EAPasscodeLockProtocol
@required
// Called when the passcode is entered correctly after dismissing the passcode View Controller
-(void)passcodeDidUnlockedSuccessfully;
@optional
// Called when the passcode is entered correctly before dismissing the passcode View Controller
-(void)passcodeWillUnlockedSuccessfully;
// Called when a passcode entered is incorrect
-(void)passcodeFailedToUnlock;
// Called when the cancel button was pressed and after the passcode View Controller is dismissed
-(void)passcodeLockWillBeCancelled;
// Called when the passcode was entered incorrectly too many times
-(void)passcodeFailedWithTooManyAttempts;
@end
Here a few screenshots of the iPad UI
Empty passcode screen
Typing the code
Wrong passcode message
Find the lastest version on GitHub: https://github.com/eaceto/EAPasscodeLock