scrollview not moving [duplicate]

2019-09-24 05:06发布

This question already has an answer here:

Quite a simple bug. Unable to resolve.

I added a scrollview to my application. Next I added a view to this scrollview which is out of scrollview bounds. I was hoping the scrollview would allow my view to be scrolled.

but the view is not scrollable. i.e. I added a button to it, to see it is scrolling horizontally. However its not.

The kind of functionality I'm looking is like infinite scrolling with a long list of buttons, similar to http://www.cocoacontrols.com/controls/infinitescrollview

How can I achieve this?

2条回答
Melony?
2楼-- · 2019-09-24 05:45

try

scr.contentSize = CGSizeMake(scr.frame.size.width, contentHeight);
查看更多
爷、活的狠高调
3楼-- · 2019-09-24 06:00

You can set the property

[scrollview setContentSize:CGRectMake(x, y, width,height)];

width = 320*no of views you want to add in scrollview

height = You can put it height view e.g. 460;

and set frame

scrollview.frame=CGRectMake(x, y, self.view.frame.size.width, height) //self.view.frame.size.width=320 (iphone)

This is the simplest way to achieve above

and if you want it with the button click then use scrollview property

[scrollview setContentOffset:(CGPoint) animated:BOOL]
or
[scrollview setContentOffset:(CGPoint)]

hope it'll help

查看更多
登录 后发表回答