Jenya Kyrmyza
Jenya Kyrmyza

Reputation: 327

Move cursor/focus on other textfield

I've added toolbar to the textfield and also on textfield it can show keyboard or show UIPickerView like on image

enter image description here

How to move cursor/focus from on textfield to other textField programmatically(Next, and Back buttons on Toolbar)?

P.S. I know how to call the method(set selector when adding UIBarButtonItem to Tool). I just need the code for moving the focus/cursor

Upvotes: 0

Views: 1365

Answers (2)

Hamish
Hamish

Reputation: 80811

Use the UIResponder methods -resignFirstResponder & -becomeFirstResponder on the respective UITextField objects to lose and gain focus respectively.

For example:

[nextTextField becomeFirstResponder];

Upvotes: 3

Viktor Starikov
Viktor Starikov

Reputation: 46

To move focus to another responder you can use[textField2 becomeFirstResponder];. I can also suggest a IQKeyboardManager library which adds a similar toolbar automatically.

Upvotes: 1

Related Questions