即使我没有动画,我的表示层也不匹配我的模型层 [英] My presentation layer does not match my model layer even though I have no animations

查看:61
本文介绍了即使我没有动画,我的表示层也不匹配我的模型层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iPhone上,我有一个 CALayer ,可以通过Core Animation进行动画处理。然后在某些时候,我改变了视图控制器。然后,我使用 CALayer 返回视图控制器,并在 viewWillAppear中:在图层上设置帧和位置属性

On iPhone I have a CALayer that I animate via Core Animation. Then at some point I change view controllers. I then return to the view controller with the CALayer and in viewWillAppear: I set the frame and position properties on my layer to move it back to its starting point.

设置这些属性会更改模型层,但是表示层仍然具有旧值,并且直到下一个表示层才会更新。我播放的动画。

Setting these properties changes the model layer but the presentation layer still has the old values and its presentation layer does not update until the next animation I play.

在CA编程指南中说:


您可以在进行动画交易时查询CALayer实例的相应
表示层。

"You can query an instance of CALayer for its corresponding presentation layer while an animation transaction is in process."

对我而言,意味着在动画制作过程中,表示层应仅与模型层不同。但是目前没有动画在运行。我什至使用 kCATransactionDisableActions 来确保在设置position属性时不会启动隐式动画。

Which, to me, implies that the presentation layer should only be different from the model layer during an animation. But there are no animations currently running. I even used kCATransactionDisableActions to ensure that when I set the position property an implicit animation is not started.

有人吗?知道为什么我的演示文稿和模型层不同步吗?

Does anyone know why my presentation and model layers are out of sync?

谢谢。

推荐答案

我使用的一种解决方法是在ViewWillDisappear中重置图层的位置。另外我还注意到,如果我不立即为图层设置动画,那么它的确会移动到我在viewWillAppear中设置的位置。

One workaround I've used is to reset the position of my layers in viewWillDisappear. Also I noticed that if I don't animate my layer right away then it does indeed move to the position that I set in viewWillAppear.

这篇关于即使我没有动画,我的表示层也不匹配我的模型层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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