0

I have got a UIScrollView with some subviews. The subviews can be expanded and folded. When the UIScrollView loads, the subviews are folded and there is no need for the UIScrollView to enable scrolling. When I expand a subview, the subviews under the expanded subview moves down. Now it can happen that the content size of the UIScrollView is not large enough when some subviews are expanded. So I try to update the contentSize like this:

`float scrollViewSizeHeight = ingredientsView.frame.size.height + recipeView.frame.size.height + tasteView.frame.size.height + nutritionView.frame.size.height + 300;

if (scrollViewSizeHeight > scrollView.frame.size.height)
{
    [scrollView setContentSize:CGSizeMake(scrollView.frame.size.width, scrollViewSizeHeight)];
    [scrollView setNeedsDisplay];
}`

New code tag is weird -.-

But when this happens, the subviews collapse and the positions get messed up. Anyone any idea why?

4

1 回答 1

0

只需在 IB 中停用自动布局

于 2013-08-29T17:19:59.617 回答