简体   繁体   English

适用于iOS的计时器1毫秒分辨率

[英]Timer 1 ms resolution for iOS

In my app I have an object(Car image) that needs to move on the screen. 在我的应用程序中,我有一个需要在屏幕上移动的对象(汽车图像)。 I need to schedule myFunction every 1ms if possible. 如果可能,我需要每1毫秒安排一次myFunction。 I read apple documentation and I understood that NSTimer resolution is limited to 50-100ms, which is not enough for my use case (moving an object quickly on the screen). 我阅读了苹果文档,并且我知道NSTimer分辨率限制为50-100ms,这不足以满足我的用例(在屏幕上快速移动对象)。

What could be the alternatives to the NSTimer object? NSTimer对象的替代品有哪些?

Thanks in advance. 提前致谢。

I think you may be trying to show things at too fine a time rate. 我认为您可能试图以太慢的速度显示事物。 The screen doesn't refresh that fast, so having a timer fire with that frequency isn't going to help. 屏幕的刷新速度并没有那么快,因此以该频率触发计时器不会有任何帮助。

For timing graphics have a look at the CADisplayLink class which calls a selector when the screen needs to be refreshed. 对于计时图形,请查看CADisplayLink类,该类在需要刷新屏幕时调用选择器。 ie A timer that is based on the display refresh rate. 即基于显示刷新率的计时器。

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

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