我在一个页面上有几个 UIScrollView.您可以单独滚动它们或将它们锁定在一起并将它们作为一个滚动.当它们被锁定时会出现问题.
I've got a a few UIScrollView on a page. You can scroll them independently or lock them together and scroll them as one. The problem occurs when they are locked.
我使用 UIScrollViewDelegate 和 scrollViewDidScroll: 来跟踪运动.我查询 UIScrollView 的 contentOffset 已更改,然后通过将其 contentOffset 属性设置为匹配来反映更改到其他滚动视图.
I use UIScrollViewDelegate and scrollViewDidScroll: to track movement. I query the contentOffset of the UIScrollView which changed and then reflect change to other scroll views by setting their contentOffset property to match.
太好了....除了我注意到很多额外的电话.以编程方式更改滚动视图的 contentOffset 会触发委托方法 scrollViewDidScroll: 被调用.我尝试使用 setContentOffset:animated: 代替,但我仍然在委托上获得触发器.
Great.... except I noticed a lot of extra calls. Programmatically changing the contentOffset of my scroll views triggers the delegate method scrollViewDidScroll: to be called. I've tried using setContentOffset:animated: instead, but I'm still getting the trigger on the delegate.
如何以编程方式修改我的 contentOffsets 以不触发 scrollViewDidScroll:?
How can I modify my contentOffsets programmatically to not trigger scrollViewDidScroll:?
实施说明....每个 UIScrollView 都是自定义 UIView 的一部分,它使用委托模式回调处理协调各种 contentOffset 的呈现 值.UIViewController 子类
Implementation notes....
Each UIScrollView is part of a custom UIView which uses delegate pattern to call back to the presenting UIViewController subclass that handles coordinating the various contentOffset values.
可以在不触发委托回调scrollViewDidScroll:的情况下改变UIScrollView的内容偏移量,通过设置 UIScrollView 的边界并将原点设置为所需的内容偏移量.
It is possible to change the content offset of a UIScrollView without triggering the delegate callback scrollViewDidScroll:, by setting the bounds of the UIScrollView with the origin set to the desired content offset.
CGRect scrollBounds = scrollView.bounds;
scrollBounds.origin = desiredContentOffset;
scrollView.bounds = scrollBounds;
这篇关于以编程方式设置 contentOffset 触发 scrollViewDidScroll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何继承 UIScrollView 并使委托属性私有How to subclass UIScrollView and make the delegate property private(如何继承 UIScrollView 并使委托属性私有)
Swift - 如何从照片库中获取最后拍摄的 3 张照片Swift - how to get last taken 3 photos from photo library?(Swift - 如何从照片库中获取最后拍摄的 3 张照片?)
使用 pagingEnabled 的 UIScrollView 中页面之间的照片应Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中页面之间的照片应用程序式间隙
为什么 UIScrollView 在 ios 6 和 ios 7 中从顶部留下空why UIScrollView is leaving space from top in ios 6 and ios 7(为什么 UIScrollView 在 ios 6 和 ios 7 中从顶部留下空间)
UIScrollView 在滚动时暂停 NSTimerUIScrollView pauses NSTimer while scrolling(UIScrollView 在滚动时暂停 NSTimer)
限制 UIScrollView 中的可滚动区域Limiting the scrollable area in UIScrollView(限制 UIScrollView 中的可滚动区域)