Home > Software engineering >  Can I know in advance where it will stop before Scrollview stops scrolling
Can I know in advance where it will stop before Scrollview stops scrolling

Time:06-04

Can I know in advance where the Scrollview will stop before scrolling stop? I have consulted relevant online materials, but it seems that there is no relevant topic. I am making a magic app to know where it will scroll before Scrollview stops, so that I can modify the value there in advance

My attempt: mark when it starts to slow down and stop, but the sliding distance between them is uncertain, so I haven't finished my idea yet

CodePudding user response:

There is a scroll view delegate method.

https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619385-scrollviewwillenddragging

This will tell you the intended target offset when the deceleration finishes.

It is intended to be used to change the target offset. For instance if you want to make sure it aligns with the content you have tween it finishes.

But you don’t have to change it. You can just return the target offset but use that to change the content like you mentioned.

  • Related