UIScrollView 委托如何知道我的 UIScrollView ivar?

发布于 2024-10-06 18:00:39 字数 498 浏览 0 评论 0原文

我正在开发一个具有分页 UIScrollView 的应用程序,其中包含三个滚动视图作为子视图,这些子视图显示可以捏合和缩放的图像。该代码来自 Apple 的“PhotoScroller”示例代码,但我已经删除了平铺功能,因为我试图首先掌握基础知识。

我可以放大不同的图像并翻阅它们,这很棒。当我离开已放大的图像以转到 pagingScrollView 的下一个“页面”时,我希望将其恢复到原始缩放大小,现在它保持在我留下的缩放级别。

我想我需要编写一些代码来告诉缩放的 UIScrollView 当我到达下一页时返回到适当的缩放比例。我的问题是我该怎么做?

到目前为止,我一直在使用UIScrollView的委托方法“scrollViewDidScroll”和“ contentOffset”属性。另一个想法是以某种方式收到 pagingScrollView 已移动到下一个“页面”的通知。

有什么想法吗?

I'm working on a app that has a paging UIScrollView that contains three scrollViews as subviews which display images that you can pinch and zoom on. The code came from Apple's "PhotoScroller" sample code but I've stripped out the tiling functionality because I'm trying to master the basics first.

I can zoom in on my different images and page through them, which is great. When I leave an image that has been zoomed in to go to the next "page" of the pagingScrollView I want it to be restored to it's original zoom size, right now it stays at the zoom level that I left it at.

I imagine I need to write some code that tells the zoomed UIScrollView to go back to the appropriate zoom scale when I get to the next page. My question is how do I do that?

So far I've been working with UIScrollView's Delegate method "scrollViewDidScroll" and and the "contentOffset" property. Another thought is somehow getting a notification that the pagingScrollView has moved to the next "page."

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

所有深爱都是秘密 2024-10-13 18:00:39

如果您有兴趣了解滚动视图何时停止(例如,用户放开并且滚动视图已捕捉到新页面上的位置),您可以使用 scrollViewDidEndDecelerating:。然而,用户可能会在允许滚动器完全停止之前滚动几页,因此用户停止的最后一页可能不是紧邻的前一页或紧邻的后一页。您可以将指针保留到当前页面,并且每次用户停在页面上时,在更新当前页面指针之前将之前的当前页面恢复到默认缩放级别。

If you're interested in knowing when the scroll view has stopped (e.g. the user has let go and the scroll view has snapped into position on a new page) you can use scrollViewDidEndDecelerating:. However, the user may scroll several pages before allowing the scroller to fully stop, so the last page the user stopped on may not be the immediately preceding or immediately following page. You can keep a pointer to the current page and each time the user stops on a page restore the previously current page to the default zoom level before updating the current page pointer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文