如何以编程方式设置 UIPageControl 的当前页面?
我在 UIScrollView 中有 3 个“页面”(第 0 页、第 1 页、第 2 页),通过手指滑动来对齐。那里也有一个 UIPageControl。 UIScrollView 从显示第 0 页开始。有时我想做的是先显示第 3 页。我怎样才能以编程方式做到这一点。
顺便说一句,简单地将(UIPageControl 的)currentPage 设置为页码没有任何作用。
I have 3 "pages" (page 0, page 1, page 2) in a UIScrollView that are snapped to by finger swipes. There is a UIPageControl there too. The UIScrollView starts off presenting page 0. What I want to do is present page 3 FIRST sometimes. How can I do this programmatically.
Simply setting currentPage (of UIPageControl) to the page number does nothing by the way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(来自PageControl示例)
要直接转到scrollView使用的特定部分,
我刚刚实现了相同的功能,例如scrollview和页面控件,并使用了
完美运行的效果,您确定pageControl出口在Interface Builder中设置正确吗(如果你正在使用它)。
如果问题是滚动视图不起作用,而不是页面控件。然后确保滚动视图的内容大小设置正确。
然后,您可以将内容添加到此滚动视图的每个部分,
下一页将被推过 1 个屏幕宽度
(From the PageControl example)
To go directly to a particular section of the scrollView use
I just implemented the same, e.g scrollview and page control and used the
which worked perfectly, are you sure that the pageControl outlet is set correctly in Interface Builder (if you're using it).
If the problem is that the scrollView is not working, and not the pageControl. Then make sure that you have the contentsize of the scrollView set correctly.
To this scrollview you then add the content to each section
Next page gets pushed over 1 screen width