Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to know the final UIScrollView contentOffset before it ends decelerating?

When user "flicks" a UIScrollView, causing it to scroll with momentum, is there a way to figure out the final contentOffset before the deceleration ends?

Basically, I would like to know what the ultimate contentOffset is from inside scrollViewDidEndDragging:willDecelerate: instead of scrollViewDidEndDecelerating:

There is a float property called decelerationRate, which might be one piece of the puzzle, but I have yet to figure out what to do with it.

PS: I have pagingEnabled set to YES. In iOS 5, there is actually scrollViewWillEndDragging:withVelocity:targetContentOffset:, but the doc says it's not fired if pagingEnabled is YES

like image 837
pixelfreak Avatar asked Jan 17 '23 22:01

pixelfreak


1 Answers

As I noticed the max contentOffset can be calculated from the start it's just a difference between the scrollview contentSize and scrollview frame size. I calculated it on y like this. maxOffsetY = scrollView.contentSize.height - scrollview.frame.size.height;

like image 146
soryngod Avatar answered Feb 13 '23 15:02

soryngod