iphone uiscrollview - 自定义分页距离
我有一个很长的 UIScrollView,我想以可变的数量进行分页(我有不同宽度的图像,当用户在启用分页的情况下滚动时,我希望这些图像在屏幕上居中:
来自 pagingEnabled 的 UIScrollView 类参考:the当用户滚动时,滚动视图停止在视图边界的倍数上。
所以我想我需要不断更改滚动视图的边界?我可以这样做,但是假设我的滚动视图的框架是 1024px 宽(在iPad)并且我想设置分页,以便下一个 500 像素宽的图像居中。如果我将滚动视图的边界更改为 500 像素宽,则它不再响应 1024 像素宽框架的其余部分中的触摸。有什么想法可以解决这个问题吗?
I have a long UIScrollView that I want to page through by a variable amount (I have images of different widths that I want to center on screen as the user scrolls through with paging enabled:
From the UIScrollView Class Reference for pagingEnabled: the scroll view stops on multiples of the view bounds when the user scrolls.
So I guess I need to keep changing the bounds of the scroll view? I can do that, but say my scroll view's frame is 1024px wide (on the iPad) and I want to set the paging so that the next image which is 500px wide gets centered. If I change the bounds of the scroll view to 500px wide, then it no longer responds to touches in the rest of the 1024px wide frame. Any ideas how to get around that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么要费心改变滚动视图的大小?
不会...
[imageView setCenter:CGPointMake(((pageYouAreOn*scrollViewWidth)-(scrollViewWidth/2.0f)),(scrollViewHeight/2.0f))];
(或类似)工作吗?why bother changing the size of the scrollview?
won't...
[imageView setCenter:CGPointMake(((pageYouAreOn*scrollViewWidth)-(scrollViewWidth/2.0f)),(scrollViewHeight/2.0f))];
(or similar) work?