TextFieldShouldBeginEditing: called multiple times for a UITextField in a UITableViewCell

This app is for the iPad, so it is based on the SDK 3.2 (behavior also appears on a later version of iOS).

I created my own UITableView cell class that contains a UITextField. The class for the cell adheres to the UITextFieldDelegate protocol, and I applied the textFieldShouldBeginEditing method to intercept user interaction with the text field.

Everything usually works fine, but I noticed that when the user scrolls the table view and then clicks on the field, textFieldShouldBeginEditing is called several times, sometimes in two different fields. This causes users to click on the field in one row of the table, and the field in the other row becomes the first responder.

Has anyone come across this behavior?

I am working on a decision to set a flag to ignore input for a fixed period of time, but I really hate doing it and would like to know if there is a way to test.

+3
source share
1 answer

I get it. I reloaded the table data at the same time as scrolling, and maybe it was a recreation of text fields.

I switched to reloading single lines, as I should have done, and it works smoothly.

+2
source

Source: https://habr.com/ru/post/1776095/


All Articles