Eric
Eric

Reputation: 1349

textFieldShouldBeginEditing: Being Called Multiple Times for UITextField in UITableViewCell

This is an iPad app so it is based on SDK 3.2 (behavior also appears on later iOS release).

I created a custom UITableView cell class which contains a UITextField. The class for the cell adheres to the UITextFieldDelegate protocol and I've implemented the textFieldShouldBeginEditing method to intercept user interaction with the text field.

Everything usually works great but I've noticed that when the user scrolls the tableview and then taps on a field the textFieldShouldBeginEditing is called multiple times, sometimes on two different fields. This leads to users tapping on the field in one row of the table and a field in another row becoming first responder.

Has anyone encountered this behavior?

I'm working on a solution to set a flag to ignore input for a fixed time period but I really hate to do this and would love to know if there is a batter way.

Upvotes: 3

Views: 1598

Answers (1)

Eric
Eric

Reputation: 1349

I figured this out. I was reloading the tableview data at the same time as scrolling and it must have been recreating the text fields.

I changed to reloading single lines as I should have been doing anyways and it is working smoothly.

Upvotes: 3

Related Questions