简体   繁体   English

如何在显示刷新率方面运行计时器?

[英]How to run a Timer in connection the the display refresh rate?

I have an object who calculate the velocity of a scrolling area. 我有一个计算滚动区域速度的对象。 When the user move up his finger off the screen, then this object fire an event every 10 ms to update the position of the scrolling (regarding to the calculated velocity) and refresh the screen (by calling setNeedsDisplayInRect of a GLKView object). 当用户将手指从屏幕上移开时,此对象每10毫秒触发一次事件,以更新滚动位置(关于所计算的速度)并刷新屏幕(通过调用GLKView对象的setNeedsDisplayInRect)。

I m just worry to synchronize my event with the actual display refresh rate (that is 60 fps normally). 我只担心将事件与实际的显示刷新率(通常为60 fps)同步。 Under ios is their any way to fire an event on each display refresh (so around every 16 ms) ? 在ios下,他们是否有办法在每次显示刷新时触发事件(因此大约每16毫秒一次)? maybe i must use cadisplayLink for this ? 也许我必须为此使用cadisplayLink吗?

Yes, it sounds like CADisplayLink Is your best bet. 是的,听起来CADisplayLink是您最好的选择。 It is designed to sync with screen refresh. 它旨在与屏幕刷新同步。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM