在 UIScrollView 上更改页面
- 作者: 阳光刺痛眼眸1990
- 来源: 51数据库
- 2022-10-20
问题描述
我有一个 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];
推荐阅读
热点文章
检查拆分键盘
0
带有“上一个"的工具栏和“下一个"用于键盘输入AccessoryView
0
Activity 启动时显示软键盘
0
UIWebView 键盘 - 摆脱“上一个/下一个/完成"酒吧
0
在 iOS7 中边缘滑动时,使键盘与 UIView 同步动画
0
我的 iOS 应用程序中的键盘在 iPhone 6 上太高了.如何在 XCode 中调整键盘的分辨率?
0
android:inputType="textEmailAddress";- '@' 键和 '.com' 键?
0
禁用 iPhone 中键盘的方向
0
Android 2.3 模拟器上的印地语键盘问题
0
keyDown 没有被调用
0
