scrollview not moving [duplicate]

本秂侑毒 提交于 2019-12-27 00:40:52

问题


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?


回答1:


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




回答2:


try

scr.contentSize = CGSizeMake(scr.frame.size.width, contentHeight);


来源:https://stackoverflow.com/questions/15612591/scrollview-not-moving

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!