Reputation: 4042
What is the best approach to hide UI elements in a UITableView with UITableViewAutomaticDimension?
I have multiple labels, buttons, imageviews in a cell. For specific condition I want to hide some of them and want the tableview to resized accordingly.
Kindly correct me if I'm missing something.
Upvotes: 1
Views: 2056
Reputation: 1758
Use StackView.
StackView will manage it, when elements hide they resize automatically. use StackView in tableview cell
Click Here for how to use StackView
Click Here For Example, This will help you to more understand.
Upvotes: 4
Reputation: 1127
If you are using UITableViewAutomaticDimension
then you must update constraints programatically.
i.e if you have 2 labels and 2 button, and if you want to hide on label on click of one of button. then you have to manage height constraints of that label to manage automatically manage cell heigh.
Upvotes: 0