使用 NSUserDefaults 到达 UIScrollView 中的某个位置
我有一个电子书风格的 iPhone 应用程序,允许用户阅读一本书。我对其进行了设置,以便当他们离开应用程序时,它会记住他们所在的页面,但不会记住页面上的确切位置(页面可以滚动相当多的距离)。
我正在使用 NSUserDefaults 让我返回页面,我想知道是否有人对我如何捕获它们在页面上的位置有任何想法...
是否有某种方法可以捕获 y 坐标位置?这是正确的方向吗?你怎么认为?
谢谢!!
I have an ebook style iPhone app that allows users to read a book. I have it setup so that when they leave the app, it remembers what page they were on, but not the exact spot on the page (the page can scroll quite a bit).
I am using NSUserDefaults to get me back to the page, I was wondering though if anyone had any ideas about how I might go about capturing the location they are on the page...
Would there be some way to capture y coordinate locations? Is that the right direction? What do you think?
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UIScrollView
有一个contentOffset
属性返回一个CGPoint
(这只是一个具有x 和 y 坐标)。例如:
UIScrollView
has acontentOffset
property that returns aCGPoint
(which is just a struct that hasx
andy
coordinates). For example:当然...
保存[scroll contentOffset];返回 CGPoint,然后在启动时设置它: [scroll setContentOffset:CGPointAnimated:YES];
根据记忆,检查语法。
Sure...
Save [scroll contentOffset]; returns CGPoint, and then set it on launch: [scroll setContentOffset:CGPoint animated:YES];
From memory, so check syntax.