Reputation: 17169
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.
Upvotes: 6
Views: 3267
Reputation: 4111
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.
Upvotes: 14
Reputation: 9101
Test your code in viewWillLayoutSubviews
. Apple say:
When a view’s bounds change, the view adjusts the position of its subviews. Your view controller can override this method to make changes before the view lays out its subviews. The default implementation of this method does nothing.
UIViewController Class Reference
Upvotes: 0