Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIScrollView setContentSize breaks view with Auto Layout

I am using Auto Layout in my iPhone app and have a UIScrollView. I need to change the content size of my scroll view at several points while my apps running (so setting the content size in viewWillAppear is useless as I have seen this suggested in other places).

When I change it, my subviews jump about, presumably because it breaks the auto layout constraints.

So how can I approach changing my scrollview content size with auto layout enabled?

Thanks.

like image 710
Josh Kahane Avatar asked Nov 18 '12 10:11

Josh Kahane


1 Answers

I was having this same issue, and I know this can't be the final solution, but for now, rather than calling this in viewWillLayoutSubviews, by putting the code inside viewDidLayoutSubviews it allowed me to set the contentSize AFTER the viewController did it's default business :)

Hope that helps.

like image 84
d2burke Avatar answered Oct 23 '22 16:10

d2burke