Jose Jose - 9 months ago 50
iOS Question

iOS 7 UIScrollView height not change

On an iPhone I have a UIViewController with a UIScrollView and I am having problems setting the height.

[_scrollView setScrollEnabled:YES];
//[_scrollView setContentSize:_viewController.frame.size];

_scrollView.contentSize = CGSizeMake(_scrollView.frame.size.width, 700);

NSLog([NSString stringWithFormat:@"%f", _scrollView.frame.size.height]);

NSLog reports 574.000000
I have done this on iPad development and works fine

Answer Source

If you want to make the frame of the scroll view bigger, use

[_scrollView setFrame:newfram];   

If you want to set the scrolling area inside the scrollView to be bigger, use

[_scrollView setContentSize:CGSizeMake(_scrollView.frame.size.width, _scrollView.frame.size.height + 300)];     // ) was missing

the previous example adds 300 pixels of extra space to the scroll view. The scroll view will only scroll how you are expecting if the content size is larger than the frame.