0
votes

I have a view that has a proportional height constraint of its superview and the multiplier is 0.09. And there is a UITableView below that view.

When I press a button I want to hide the top view completely and when I tap that button again I want to display it again.

Since it has a proportional height constraint and has a multiplier, I cannot directly change its constant. I need to create a new constraint and assign that constraint to that view. I have tried changing multiplier and assigning it, it worked and hidden the view but when I wanted to display it again and set the multiplier to 0.09 it didn't work.

Do you have any solutions?

Thanks.

1
Just set .hidden = YES;?Cy-4AH
@Cy-4AH But I want to move the tableView upBurak Akyalçın
multiplier is read only property. How you managed to change it?Cy-4AH
created a new constraint with current values and changed the multiplier only.Burak Akyalçın
An alternative is to embed your view in a UIStackView. When you hide the content inside a UIStackView, it automatically shrinks, moving your table view up.Rodrigo Morbach

1 Answers

0
votes

first off, you shouldn't code a view like that above the UITableView that will be shrunk and then force the UITableView to resize. Doing it this way is prone to brokenness. The easist way to achieve this is make the view at the top a header of the UITableView. And when the button is pressed, you "realoaddata" on the UITableView which will then call the header view height delegate method where you then change the height based on a boolean value or something. Don't do what you're doing. also, use a collection view instead. good luck