I have following hierarchy in UITableViewCell.
UITableViewCell
-UIView1
--UILabel1
-UIView2
--UILabel2
I want UIView1 to be hidden by height when UILabel1 have no text. For that I have taken a height constraint of 0 for UIView1 with initially uninstalled state.
Now in cellForRowAtIndexPath I am activating this constraint when i check the string for Label1 is empty or not?
This is not working for the first load of the cell and when i scroll through the tableview this constraint is applied. I am using [cell layoutIfNeeded] after activating constraints but it seems not to be working here for first load.
How can i crack this issue?
I managed to solve this by creating two constraints and changing their priorities in runtime.
The constraint priority happens in layoutSubviews()
of subclassed UITableViewCell.
Hope this helps !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With