PDA

View Full Version : UIScrollView does not scroll




portem1
Jan 18, 2011, 05:52 AM
Hello,

I have an UIScrollView that I fill dynamically with UILabels.
At the end I need to allow scrolling if the contents are larger than the containing view.
I try to do this with:
scrollhowtouse.frame=CGRectMake(0,0,320, yf);
where yf is the end position calculated by my program.
But doing so just displays the full screen and scrolling is not possible.

What point do I miss here?

Thanks for your answers



Steven Jobson
Jan 18, 2011, 06:07 AM
A lot of factors left out to fully know why the problem is. Is yf defined before that line is executed? Is 0, 0, and 320 already initialized?

portem1
Jan 18, 2011, 03:51 PM
A lot of factors left out to fully know why the problem is. Is yf defined before that line is executed? Is 0, 0, and 320 already initialized?

Yes, 0, 0, 320 is already initialized

robbieduncan
Jan 18, 2011, 03:55 PM
The UIScrollView should be sized to the screen/space you want it in (this is the frame). The UIScrollViews contentSize (http://developer.apple.com/library/ios/documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/occ/instp/UIScrollView/contentSize) property should be set to the size of the content view. If the contentSize is larger than the frame (and scrolling is enabled) then you can scroll the content.

portem1
Jan 19, 2011, 06:33 AM
The UIScrollView should be sized to the screen/space you want it in (this is the frame). The UIScrollViews contentSize (http://developer.apple.com/library/ios/documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/occ/instp/UIScrollView/contentSize) property should be set to the size of the content view. If the contentSize is larger than the frame (and scrolling is enabled) then you can scroll the content.

Thanks, i did like you said and it works!