Xavi Valero Xavi Valero - 3 months ago 56
iOS Question

Keypressed event in UITextField

I have 10 textfields, in which I could enter only one character in each textfield. After a character is entered in each textfield, the focus should move to the next one. Similarly when i delete character from a textfield by pressing the backspace or delete, i need to get the focus to the previous textfield. If I could get the keypressed event, I could do that. Right now I am not able to find any keypressed event examples.


Implement UITextFieldDelegate.

Implement the delegate methods in the protocol. You can achieve the things you wanted.

You can set the focus by using the method becomeFirstResponder to the required textfield.

Have a look at the delegate method

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

The text field calls this method whenever the user types a new character in the text field or deletes an existing character.

So that could solve your problem.