- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
什么时候使用iOS quartz核心框架的CADisplayLink。 NSTimer 和 CADisplayLink 是一样的吗?什么是正确使用 CADisplayLink?我们要同步ios uiview的绘图
最佳答案
无耻地复制/粘贴the official documentation :
A CADisplayLink object is a timer object that allows your application to synchronize its drawing to the refresh rate of the display.
Your application creates a new display link, providing a target object and a selector to be called when the screen is updated. Next, your application adds the display link to a run loop.
Once the display link is associated with a run loop, the selector on the target is called when the screen’s contents need to be updated. The target can read the display link’s timestamp property to retrieve the time that the previous frame was displayed. For example, an application that displays movies might use the timestamp to calculate which video frame will be displayed next. An application that performs its own animations might use the timestamp to determine where and how displayed objects appear in the upcoming frame. The duration property provides the amount of time between frames. You can use this value in your application to calculate the frame rate of the display, the approximate time that the next frame will be displayed, and to adjust the drawing behavior so that the next frame is prepared in time to be displayed.
Your application can disable notifications by setting the paused property to YES. Also, if your application cannot provide frames in the time provided, you may want to choose a slower frame rate. An application with a slower but consistent frame rate appears smoother to the user than an application that skips frames. You can increase the time between frames (and decrease the apparent frame rate) by changing the frameInterval property.
When your application finishes with a display link, it should call invalidate to remove it from all run loops and to disassociate it from the target.
CADisplayLink should not be subclassed.
关于ios - CADisplayLink iOS有什么用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36640154/
在 Objective-C 中,我们可以使用代理模式初始化 CADisplayLink 来打破强引用: WeakProxy *weakProxy = [WeakProxy weakProxyForOb
我正在尝试制作一个应用程序,我必须触摸在屏幕上移动的按钮。我正在使用 CADisplayLink 来实现此目的。我的代码中的问题是它创建了一个新按钮而不是使用特定的按钮: @IBOutlet var
我在网上和文档中都找不到任何直接的答案。如果我使用以下内容设置 CADisplayLink: let displayLink = CADisplayLink(target: self, select
我正在尝试使用CADisplayLink来实现游戏循环的恒定帧速率。当在模拟器中测试它时,我无法实现稳定的时间范围。我应该考虑采用不同的方法吗? 或者这只是因为模拟器无法正确模拟硬件? 根据 Appl
我一直徒劳地试图理解 CADisplayLink.timestamp 的浮点值是什么。以纳秒为单位吗?秒?它的精度是多少? 最佳答案 文档 here声明该属性属于 CFTimeInterval 类型,
我将 CADisplayLink 用作选通计时器。 我有 2 个 CADisplayLinks: 主要的(在整个过程中运行): SMPTELink = [CADisplayLink displayLi
这是我的第一篇文章。如有错误,请多多包涵。 我是 iPhone 开发新手。我正在使用 CADisplayLink 来执行我的游戏的“更新”循环。在 XCode 8.2 中,我使用以下代码来计算两个连续
我的应用程序有问题。我想要发生的是当我单击按钮 2 时,它消失并停止移动。现在发生的事情是,当我单击 button2 时,它会消失但不会停止移动(即使它是隐藏的)。有帮助吗?代码: @IBOutlet
对于我的游戏循环和某些动画,我想知道自上次调用 render: 方法以来耗时间隔。 为此,我使用 CADisplayLink 并获取当前时间戳并减去上次调用的时间戳。这应该给我两个帧/调用之间的正确时
我用 CADisplayLink 替换了 NSTimer。我让它工作正常,但运行速度太慢。我怎样才能加快速度?这是我正在使用的代码: 在接口(interface)中我声明了一个实例变量: CADisp
我注意到在使用 CADisplayLink 时,异常会被吞没: CADisplayLink *aDisplayLink = [[UIScreen mainScreen] displayLinkWith
什么时候使用iOS quartz核心框架的CADisplayLink。 NSTimer 和 CADisplayLink 是一样的吗?什么是正确使用 CADisplayLink?我们要同步ios uiv
尝试重现 this article 中描述的行为.逐行。一切正常,但最后一步...... 问题是:我在调用 UIView.animate 之前取消暂停 CADisplayLink 并期望取消暂停的 C
我在我的应用程序中使用 CADisplayLink 作为计时器。我正在使用 CADisplayLink,因为我的应用程序非常依赖 CADisplayLink 的准确度/精度。就我而言,NSTimer
我正在制作游戏,我想在不同的线程上运行游戏逻辑代码和渲染代码,以期提高性能。但对于我来说,我无法弄清楚如何在生成的线程中运行 CADisplayLink。现在我正在使用 NSThread 进行多线程处
好吧,几个小时以来,我一直被这个编译器错误完全难住,问题是我所做的所有谷歌搜索都说它应该按照我的方式工作!我正在学习一本关于 iPhone 游戏开发的书籍教程,但由于随机编译错误,我卡在了第二章。 注
我有一个 CADisplayLink 触发 Director 对象中的 draw 方法。我想使 CADisplayLink 无效,然后解除分配一些由 Director 对象使用的单例缓存对象。 dra
我发现了 CADisplayLink 的一个大问题。 我有最基本的 EAGLLayer 和 OpenGL ES 1.1 绘制一个旋转三角形用于测试。这需要一个以屏幕刷新率调用的运行循环方法,所以我这样
我在我的 iOS 应用程序中使用了 NSTimer,但由于 SetNeedsDisplay,我没有得到我想要的结果。 我做了一些研究并找到了 CADisplayLink,它为我提供了我想要的动画结果。
如上一篇文章 ( Here ) 中所述,我正在创建一个从初始角度开始并移动到结束角度的动画。我决定使用 CADisplayLink 来实现此动画,因为动画需要在用户输入期间尽可能快地运行,因此使用 C
我是一名优秀的程序员,十分优秀!