滚动视图不动 [英] scrollview not moving
问题描述
很简单的错误.无法解决.
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.
我正在寻找的功能就像带有一长串按钮的无限滚动,类似于 http://www.cocoacontrols.com/controls/infinitescrollview
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?
推荐答案
可以设置属性
[scrollview setContentSize:CGRectMake(x, y, width,height)];
width = 320*您想在滚动视图中添加的视图数量
width = 320*no of views you want to add in scrollview
height = 你可以把它放在高度视图 例如 460;
height = You can put it height view e.g. 460;
并设置框架
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)]
希望能帮到你
这篇关于滚动视图不动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!