Is there a way to size a make a UIScrollView auto adujust to the height (or width) of the content it's scrolling?
something like:
[scrollView setContentSize:(CGSizeMake(320, content.height))];
Thanks
Is there a way to size a make a UIScrollView auto adujust to the height (or width) of the content it's scrolling?
something like:
[scrollView setContentSize:(CGSizeMake(320, content.height))];
Thanks
it depends on the content really : content.frame.height might give you what you want ? Depends if content is a single thing, or a collection of things.
UIScrollView doesn't know the height of its content automatically. You must calculate the height and width for yourself
Do it with something like
CGFloat scrollViewHeight = 0.0f;
for (UIView* view in scrollView.subviews)
{
scrollViewHeight += view.frame.size.height;
}
[scrollView setContentSize:(CGSizeMake(320, scrollViewHeight))];
But this only work if the views are one below the other. If you have a view next to each other you only have to add the height of one if you don't want to set the content of the scroller larger than it really is.