简单的动画不工作的iOS7 [英] Simple animation not working on iOS7

查看:243
本文介绍了简单的动画不工作的iOS7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林用一个按钮来触发下面的动画:

Im using a button to trigger the following animation:

newPosition1=CGPointMake(200.0f + _btnAgregar.frame.size.width/2.0f, _btnAgregar.center.y);
    [UIView animateWithDuration:0.5f animations:^{
        _btnAgregar.center=newPosition1;
    }];

这对iOS7运行工作时iOS8上运行的任何设备上得很好,但也绝对没有什么。

It works just fine on any device running on iOS8, but does absolutely nothing when running on iOS7.

任何想法,为什么?谢谢你。

Any idea why? Thanks.

推荐答案

根据您的意见,您得到的关于该日志输出到这个按钮:

According to your comments, you are getting this log output in regards to this button:

<UIButton: 0x7fded8c9df60; frame = (185 3; 25 25); 
opaque = NO; autoresize = RM+BM; tag = 4; 
animations = { position=<CABasicAnimation: 0x7fded8ce4eb0>; }; 
layer = <CALayer: 0x7fded8c98920>>

所以这个按钮的的动画正在以自己的立场。在iOS中7,试图动画的属性时,该属性已经被动画会导致动画的取消。你需要追查按钮被这个code运行之前的动画。

So this button is already being animated as to its position. In iOS 7, trying to animate an attribute when that attribute is already being animated will cause cancellation of the animation. You need to track down why the button is being animated before this code runs.

问题不会在iOS中发生8的原因是,有动画是如何工作的一个变化 - 多个动画上相同的属性是附加的(见关于这一主题的2014年WWDC视频)

The reason the problem doesn't happen in iOS 8 is that there was a change in how animation works - multiple animations on the same attribute are additive (see the WWDC 2014 video on this topic).

这篇关于简单的动画不工作的iOS7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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