0

I have a custom UITabelViewCell class that also implements UITextFieldDelegate

I also implement textFieldDidEndEditing so that once a field is done being edited I get a call back so that I can store the value that was typed in back in to the data array that loads the table

Seems like I have to do this or the data array never gets the type in values.

I edit various rows and when I click to the next row i get the textFieldDidEndEditing for the previous cell as expected. So far so good.

Now the problem. In the last cell I edit the cursor is still in the UITextField. I click a button to 'evaluate' the list of items in the table. Clicking the button to 'evaluate' the table causes its routine to kick off immediately. HOWEVER, the 'evaluate' finishes BEFORE get the final textFieldDidEndEditing for the field where my cursor was sitting.

That is, i do get the textFieldDidEndEditing for the field where my cursor was sitting but I don't see that call back until too late. i have already 'evaluated; the array and then afterwards I stuff the last typed value in to the data array that load the table.

How do I get the 'evaluate' to wait on the last textFieldDidEndEditing (IF there is one to come)? OR what do people typically do? Put in some kind of pause for my 'evaluate' so that there is time for the textFieldDidEndEditing callback to happen first?

I have a separate question on a second but related problem here Know the row number inside custom UITableViewCell - new wrinkle

Community
  • 1
  • 1
john
  • 505
  • 1
  • 7
  • 15
  • Have you tried using `[self.view endEditing:YES]` as soon as the button is clicked and before the *evaluate* logic is started? – Rikh Jan 15 '17 at 04:15
  • I did both **tableView.endUpdates()** and **tableView.isEditing = false** The textFieldDidEndEditing call back is too slow. I don't get the textFieldDidEndEditing call back until after the 'evaluate' is done so the last entered row is always wrong because it does not have its value! Frustrating. iOS makes it really difficult to have an editable field in a table row. Is there some safe way to delay? Not sure how long would delay to guarantee the callback has come. – john Jan 15 '17 at 08:49
  • thought i added this comment already... Did no realize endEditing was different from endUpdates and isEditing= False. I added endEditing and all is fine. This Rikh. That addition makes sure the final edit call back happens in time – john Jan 16 '17 at 21:23

0 Answers0