如何确定scrollviewer何时结束滚动? [英] How to determine when the scrollviewer has ended scrolling?

查看:214
本文介绍了如何确定scrollviewer何时结束滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在用户完成滚动后将scrollviewer调整到某个点。



iOS的UIScrollView有一些类似的方法

   - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView时调用scrollview 

- (void)scrollViewDidEndDecelerating :( UIScrollView *)scrollView

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)减速

我尝试了 ViewChanging ViewChanged ,但是同时处理这两个事件的问题是他们一个接一个。如下:



查看更改



查看更改



查看更改



查看已更改



..



..



而不是 -



查看更改



查看更改



查看更改



查看更改



查看更改



有没有办法我可以获得当scrollviewer完成滚动或完成滚动通过拖动的通知?



请帮助。

解决方案




  • 1.捕获 MouseWheel 事件。

  • 启动 MouseWheel 的事件处理程序中的一个线程,这将计算时间来提升自定义事件,例如 FinishedScrolling

  • 3.如果在定时器完成之前发生 MouseWheel 事件,意味着滚动'/'>


怎么办?它不应该占用太多的代码,如果你使用MVVM,你可以使用附加行为。


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.

解决方案

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 like FinishedScrolling
  • 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.

这篇关于如何确定scrollviewer何时结束滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆