Rows Become Permanently Hidden#32
Rows Become Permanently Hidden#32chulbert wants to merge 1 commit intomarlimox:masterfrom chulbert:master
Conversation
| cell.layoutIfNeeded() | ||
| UIView.animate(withDuration: 0.3) { | ||
| cell.isHidden = isHidden | ||
| cell.layoutIfNeeded() |
There was a problem hiding this comment.
Is this second layout call needed now?
There was a problem hiding this comment.
Yes, it is the second call, within the animation block, that actually animates the constraint change (via isHidden).
That said, I spoke too soon and this did not actually fix my problem. What is happening is multiple calls to setRowHidden(true) are "accumulating" and setRowHidden(false) does not take effect until it's called enough times to "balance" all the hides. There is a unit test in the project for this scenario - and it passes - but that is exactly what I'm seeing.
I've presently wrapped the call to setRowHidden() in isRowHidden() to execute only when there's a change but that's, well, gross. I'm perplexed.
|
@chulbert @marlimox I think this is more related to this bug in the UIStackView. I think your wrapper |
|
Oh, I found that it was merged here 👍 |
|
@crabman448 You're exactly right. Thank you. |
We have a stack view with a row whose hidden state is animated and dependent on user input in a text field meeting certain criteria. As a result, setRowHidden() is called many times in relatively rapid succession with each keystroke. We have seen many scenarios where a succession of setRowHidden(true) renders the row permanently hidden - setRowHidden(false) does nothing. If animation is disabled this issue does not occur.
I believe this is due to overlapping layout operations inside the UIView.animate block of setRowHidden() when called multiple times. My understanding of best practices and guidance from Apple is to call layoutIfNeeded() prior to the animation block to complete/flush any pending layout operations. I have made this change and it resolves the issue.