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.
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.
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.
How can I modify my contentOffsets programmatically to not trigger scrollViewDidScroll:
?
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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…