Created
September 18, 2012 12:49
-
-
Save jlcampana/3742910 to your computer and use it in GitHub Desktop.
Emulate PIN unlock screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@property (strong, nonatomic) IBOutlet UITextField *pin1_1; | |
@property (strong, nonatomic) IBOutlet UITextField *pin1_2; | |
@property (strong, nonatomic) IBOutlet UITextField *pin1_3; | |
@property (strong, nonatomic) IBOutlet UITextField *pin1_4; | |
@property (nonatomic, strong) NSString *pinText; | |
- (void)viewDidLoad | |
{ | |
(...) | |
[self.pin1_1 setDelegate:self]; | |
[self.pin1_2 setDelegate:self]; | |
[self.pin1_3 setDelegate:self]; | |
[self.pin1_4 setDelegate:self]; | |
} | |
-(UITextField *)nextPinFieldTo:(UITextField *)textField | |
{ | |
if(textField == self.pin1_1) | |
{ | |
return self.pin1_2; | |
} | |
else if(textField == self.pin1_2) | |
{ | |
return self.pin1_3; | |
} | |
else if(textField == self.pin1_3) | |
{ | |
return self.pin1_4; | |
} | |
else | |
{ | |
return nil; | |
} | |
} | |
-(BOOL)textFieldShouldReturn:(UITextField *)textField | |
{ | |
[textField resignFirstResponder]; | |
return YES; | |
} | |
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField | |
{ | |
return YES; | |
} | |
-(void)textFieldDidEndEditing:(UITextField *)textField | |
{ | |
textField.text = self.pinText; | |
if (textField == self.pin1_4) | |
{ | |
[self login]; | |
} | |
else | |
{ | |
[[self nextPinFieldTo:textField] becomeFirstResponder]; | |
} | |
} | |
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)newString | |
{ | |
self.pinText = newString; | |
[textField resignFirstResponder]; | |
return NO; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment