0
votes

I've got a UITableViewCell subclass here that manages a UITextField setup on the right side of the table view cell. Anywhere from 4 to 8 of these cells are displayed at any given time depending on the table; I use them for unit data entry (ie, entering in distances, temperatures, etc) so there's quite a bit of logic bolted to the cell subclass.

For whatever reason, I've noticed that if I perform the following steps:

1) Tap on a text field to begin editing and bring up the keyboard
2) Enter in some text
3) Tap the clear button (which is enabled on the text field)
4) Tap on another textfield in the same table view

Then the current UITextField loses focus, but the second text field does not gain it. This means that no UITextField currently has focus, but the keyboard is still being displayed on-screen... but without any active text field, it does nothing, and cannot be dismissed (presumably because there's no first responder to resign?).

I can then tap on another text field again, and it will take focus and begin editing- at which point the keyboard becomes operable again and pressing the return/done key will dismiss it and end editing as usual.

If I simply tap on another UITextField without first hitting a button, then the second UITextField will gain focus immediately (as I'd expect it to). But it seems like button presses outside of the UITextField will cause this behaviour to occur if you try to switch fields after tapping any kind of button other than the text field.

Does anyone know what is causing this? It almost sounds like there's something wrong with the responder chain, but I'm not sure what the problem would be or how to fix it.

2

2 Answers

0
votes

Firstly,you are sure the textfiled in the table has a unique identifier ,such as tag. Secondly,you should make another textfiled become first responder if you want a textfiled lost first responder but the keyboard still appear.

0
votes

Figured out what it was...

The problem was that I was reloading the table data in the delegate method that my custom cell was calling upon edit completion. Apparently reloading the tableview data while you're in the middle of switching UITextFields will cause the second text field to not gain focus (but the keyboard won't get dismissed), hence causing the issue I was seeing.