SnakingPrabhu
SnakingPrabhu

Reputation: 156

cursor automatically move from one uitextfield to other textfield in ios?

I have 4 uitextfield controls if textfield length is 1 move to next uitextfield and hitting backspace delete one by one textfield text in reverse direction.

like ipad unlock passcode while startup.

Upvotes: 0

Views: 1355

Answers (1)

wigging
wigging

Reputation: 9170

You can use the UITextField delegate method to move to the next text field:

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    if (textField == textFieldA) {
      [textField resignFirstResponder];
      [textFieldB becomeFirstResponder];
    } else if (textField == textFieldB) {
      // etc...
    }
return YES;
}

For the Delete or Backspace key you try something like this:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

Other than that, I don't know of any other ways to catch keyboard events in iOS.

Upvotes: 2

Related Questions