cannyboy cannyboy - 1 year ago 84
iOS Question

UIScrollView contentSize not working

I put a

in my nib's
, and linked it to a an

Now, when I do this in my
method, it seems to have no effect on the
: = [UIColor yellowColor]; // this works
CGSize size = CGSizeMake(1000.0, 1000.0);
[ setContentSize:size]; // this does not

It behaves as if the
was the same as the frame. What's going on?
This started working when I turned off AutoLayout. Why?

yuf yuf
Answer Source

I had the same problem. Auto Layout for UIScrollView is messed up.

Work around: Put everything in the UIScrollView into another UIView, and put that UIView as the only child of the UIScrollView. Then you can use Auto Layout.

If things near the end is messed up (the end of whichever direction your UIScrollView scrolls), change the constraint at the end to have the lowest possible priority.