1

I have a UIScrollView with a UIView inside it and 3 UITableViews inside the view and I have the following constraints for the view :

enter image description here

In my code, exactly in ViewDidLayoutSubviews I have the following code

- (void)viewDidLayoutSubviews { [_containerScrollView setContentSize:CGSizeMake(SCREEN_WIDTH * 3, [_containerScrollView frame].size.height)]; [_contentViewWidthLayoutcontraint setConstant:SCREEN_WIDTH * 3]; [[self view] layoutIfNeeded]; } 

Which change the view width realtivly to the screen width.

My question is why there is no conflict between the width constraint and the leading/trailing constraints ?

1 Answer 1

2

With your layout constraints, View's frame size is now become ScrollView's contentSize. So if you change _contentViewWidthLayoutcontraint's constant, it is same as you change ScrollView contentSize.width.

Note that ScrollView.frame.size and ScrollView.contentSize are totally different.

Sign up to request clarification or add additional context in comments.

3 Comments

so you mean I can remove the first line in my code?, also I have a problem with width and leading/trailing constraints. Aren't they conflicted ?!
Yes, you can remove first line.
Width and lead/trailing may have conflict in some cases, like UIView.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.