I have a UIScrollView, and inside that, a UIView that defines the ContentSize of the ScrollView. Inside that ContentView, I have a couple of different Views, that are all of equal width (the maximum width), and all have proportional height to the Superview (even above the UIScrollView). The setup works perfectly and the scrolling works.
Now, I want to be able to hide one of those UIViews if there is no content to be shown inside, and in doing so, I want the other views to resize themselves to they fill up the blank space left behind.
I have a height constraint of that particular UIView to the Superview with a multiplier of 0.3 I added a second height constraint, of the exact same UIView to the exact same Superview with a multiplier of 0.01, but a lower priority, so that it doesn't affect it at runtime. (I've tested the situation: if I put the 0.3 multiplier on lower priority and the 0.01 multiplier on higher priority, everything is resized perfectly, exactly like I want it).
Now I created two outlets with connections in my header files, and here is the code I use when I want to make the change:
//DescriptionViewNormalConstraint is the 0.3 height one, with 1000 priority
descriptionViewNormalConstraint.active = NO;
//DescriptionViewInvisibleConstraint is the 0.01 height one, with 500 priority
descriptionViewInvisibleConstraint.active = YES;
[self.view setNeedsLayout];
[self.view layoutIfNeeded];
But this doesn't work. In fact, it changes nothing. What am I missing here?
descriptionViewNormalConstraint
remains active? - ddbsetNeedsLayout
andlayoutIfNeeded
over the specific view to which you attached these constraints? - ddbdescriptionViewNormalConstraint
after you de-activated it? - ddb