开发者

iPhone Recalculate Scroller Content Height?

开发者 https://www.devze.com 2023-01-23 07:45 出处:网络
I am adding a bunch of boxes into a UIView inside of a UIScrollerView. The content of the UIView goes beyond the bottom of the device\'s screen and should cause the whole scene to scroll.

I am adding a bunch of boxes into a UIView inside of a UIScrollerView. The content of the UIView goes beyond the bottom of the device's screen and should cause the whole scene to scroll.

However, thi开发者_StackOverflows isn't happening. The content gets added but the scene will not scroll. I assume it has to do with UIKit not automatically resizing the UIView container to match the overflowed content (I can understand why), so I tried setting the new bounds rectangle with [container setBounds: CGRectMake(0, 90, 768, 230*20)], with the 20 being the number of boxes (the height of each is 230). When I do this, nothing appears at all...

Anyone know why the content doesn't reappear or does anyone have another solution for making the UIScrollView scroll?


You should set the contentSize of scrollview, to match your UIView's size.

Please see

http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/occ/instp/UIScrollView/contentSize

0

精彩评论

暂无评论...
验证码 换一张
取 消