在 UIScrollView 上更改页面 [英] Change page on UIScrollView

查看:12
本文介绍了在 UIScrollView 上更改页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 10 页的 UIScrollView.我可以在它们之间轻弹.我还想要 2 个按钮(一个后退按钮和一个下一个按钮),当触摸它们时会转到上一页或下一页.我似乎无法想出办法来做到这一点.我的很多代码都来自 Apple 的页面控件示例代码.有人可以帮忙吗?

I have a UIScrollView with 10 pages. I am able to flick between them. I also want to have 2 buttons (a back button and a next button) which when touched will go to the previous or next page. I can't seem to figure out a way to do this though. A lot of my code comes from Apple's page control sample code. Can anybody help?

谢谢

推荐答案

你只需告诉按钮滚动到页面的位置:

You just tell the buttons to scroll to the page's location:

CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * pageNumberYouWantToGoTo;
frame.origin.y = 0;
[scrollView scrollRectToVisible:frame animated:YES];

这篇关于在 UIScrollView 上更改页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆