4

I have placed multiple UITextFields into an UIViewController in the storyboard.
I am using IQKeyboardManager to scroll the UITextFields over the keyboard when they are focused.

IQKeyboardManager toolbar

When I click the next button in the keyboard toolbar, another UITextField is getting focused while the current one loses focus.

How can I control the order of the focus of the UITextFields by the keyboard toolbar buttons?

Colin Wang
  • 6,778
  • 5
  • 26
  • 42

2 Answers2

6

Set IQAutoToolbarManageBehaviour

In your case could be

IQKeyboardManager.sharedManager().toolbarManageBehaviour = .byTag

Then add tag to your TextFields

textField1.tag = 1
textField2.tag = 2
textField3.tag = 3
Haroldo Gondim
  • 7,725
  • 9
  • 43
  • 62
3

After hours of research, I found that the focusing order of UITextFields depends on the order of the XML nodes in the storyboard file.

The order of the XML nodes of <code>UITextField</code>s

As a result I changed this order and everything works fine as I wanted.

Colin Wang
  • 6,778
  • 5
  • 26
  • 42
  • 1
    for those who don't want to edit the raw xml, setting the order in storyboard or xib will also do – jackal Apr 11 '19 at 19:14