I had this structure on my storyboard (i have added some example name to easly understand):
UIView (the main view) "BlackView"
-UIScrollView (inside the main view) "OrangeView"
- UIView "YelloView" (ContentView inside main scroll)
- UITableView "BluView" (Inside and on the top of the contentView)
- UIView "RedView" (Inside of the ContentView and on the same level of UITableview)
- UIView "YelloView" (ContentView inside main scroll)
What i wanna achive? I want a table that grow proportionally to his rows number (the row height is fixed to 60). I also want an UIScrollview that grow in content_size and scroll ability accordingly to the heights sum of the BlueView and the RedView.
The autolayout constraints are:
UiScrollView "OrangeView": (top 0,trailing 0,bottom 0,leading 0)
UIView "YelloView": (top 0,trailing 0,bottom 0,leading 0) (equal width to main ed equal height to main "BlackView" , priority “low” for bottom)
UITabelView "BluView": (top 0,trailing 0,leading 0)
UIView "RedView": (Vertical space 2 to "BluView",trailing 0,leading 0,bottom 0 to YelloView)
I have a complete chain of constraints from top to bottom of the view. UITableView is free to grow because i haven't set directly his "height" constraint and uitableview setscrollingenabled is FALSE. The result is a tableview that don't grow.
I can produce the growing by code:
Table.frame=CGRectMake(BluView.frame.origin.x, BluView.frame.origin.y, BluView.frame.size.width, BluView.contentSize.height);
I works, the table frame and the "OrangeView" scroll content_size grow correctly but "RedView" doesn't respond to this frame change and it doesn't move to the new "table bottom" ad 2 of distance.
What i have already tried to refresh the constraints system:
[BlackView layoutIfNeeded];
[BlackView setNeedsUpdateConstraints];
[RedView layoutIfNeeded];
[ScrollContainer layoutIfNeeded];
[RedView layoutIfNeeded];
[RedView setNeedsUpdateConstraints];
[OrangeView setNeedsUpdateConstraints];
[RedView updateConstraints];
[OrangeView updateConstraints];
[BlackView updateConstraints];
[BluView setTranslatesAutoresizingMaskIntoConstraints:NO];
[RedView setTranslatesAutoresizingMaskIntoConstraints:NO];
I have called those methods before and after the uitable frame change, they doesn't refresh the RedView's y position. How i can obtain the desired behaviour? There's a way to create anothere type of "costraints tree" or maybe there's another way to refresh the position of the RedView after i have programmatically change the Tableview frame?