开发者

Strange Problem with disappearing Cells containing UITextFields in UITableView

开发者 https://www.devze.com 2023-01-07 13:37 出处:网络
I have a screen which functions similarly to the address book contact screen. The screen displays some data in a UITableView and provides an \"Edit\" button.

I have a screen which functions similarly to the address book contact screen.

The screen displays some data in a UITableView and provides an "Edit" button.

When the user presses "Edit" the UITableView is animated to display the data in "Edit Mode".

There is not a 1:1 relationship between the fields in "View Mode" and the fields in "Edit Mode". For example, the "View Mode" cell might contain a name like "John Doe" and the edit mode might have two cells, one for "First Name" and one for "Last Name".

The cells in "Edit Mode" contain a label on the left and a UITextField on the right (just like contacts).

All of this works great. No problems. Adjusting for the Keyboard and everything. Love it.

The problem i'm having is when the user clicks "Edit", and clicks inside one of the UITextFields but never presses the "Next"/"Done" button --- and the keyboard is still showing (the UITextField is still firstResponder) ---

If, while the UITextField is still firstResponder, the user presses the "Done Editing" button, and the table animates back to "View Mode", and the user re-enters "Edit Mode", one of the UITableViewCells will be missing (randomly, because they are reused).

If开发者_开发技巧 the user then repeats the process on another UITextField, then two cells will be missing the next time in, etc etc etc.

My theory is something isn't being released properly, and that is causing the cell reuse mechanism to break somehow... but I'm fairly sure it's not a problem with my code per-se.

My question is; has anyone seen this before? Is this a known problem?

I can force any UITextField firstResponder to resign when the user clicks the "Done Editing" button, by making my view firstResponder (and this does fix the problem)... but I'm a bit surprised I'd have to do this. I guess I'm looking for confirmation that I am/am-not crazy.

Thanks


Looks like no one has any answer, so:

Force the UITextField to resign first responder and the problem goes away.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号