Reputation: 190
So here's the description of the loop my app keeps falling on:
There is a UITableView containing ReactiveTableViewCell's (but I think RX part doesn't really matter here, so let's pretend these are UITableViewCell). Each cell embeds a UITextField upon an expandable/collapsable UIView (that allows me to show any error message related to the textfield) - when there is no error to show, this subview is collapsed.
The thing is, when UITableView gets scrolled and makes reuse of an "errored" cell, the subview of this cell is still expanded. As PrepareForReuse() method is made to reset cell state before a reuse, I thought it would be the right place to collapse the subview, and indeed it does... until the app falls into a loop, resizing top-screen and bottom-screen same cell forever.
How do you think I could fix this issue? Maybe is there a way to increase cell reuse tolerance so UITableView won't reuse a cell as soon as it disappeared from screen? Maybe shall I have a try with a resize-lock while list is being scrolled, but it will always leave some margin for error so it's not the fix I'm looking for.
Thanks for your help.
EDIT :
Well, it seems like the RX part was not so clueless. The IObservable I was subscribing to, aiming to show the error message, was a ReplaySubject. It appears that looping was happening on there due to this little guy, refreshing the UITableView (through TV.BeginUpdates/TV.EndUpdates) endlessly. So by now I assume ReplaySubject and cell-reuse won't work well altogether, since a simple replacement with a BehaviorSubject fixed the issue.
Upvotes: 1
Views: 87