问题
I need to adjust the scrollviewer to some point after the users has completed scrolling. For that i need to get to listen to when the scrolling has ended.
iOS's UIScrollView has some similar methods
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView that is called when the scrollview
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
I tried ViewChanging
and ViewChanged
, But problem with handling both events simultaneously is that they occur one after another. Like following:
view changing
view changed
view changing
view changed
..
..
instead of -
view changing
view changing
view changing
view changing
view changed
Is there any way i can get the notification for when the scrollviewer has done scrolling or done scrolling-through-dragging?
Please help.
回答1:
What You could do is :
- 1.Capture
MouseWheel
event. - 2.Fire up a thread in the event handler of
MouseWheel
, that would count time to raise a custom event of yours likeFinishedScrolling
- 3.If a
MouseWheel
event gets raised before the timer finishes, that means that the scrolling isn't done and you should terminate your timer-thread and start it again.
How's that ? It shouldn't take up too much code and if you're using MVVM you could use an Attached Behaviour.
来源:https://stackoverflow.com/questions/21234210/how-to-determine-when-the-scrollviewer-has-ended-scrolling