andres25
andres25

Reputation: 89

Simple animation not working on 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;
    }];

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

Any idea why? Thanks.

Upvotes: 0

Views: 59

Answers (1)

matt
matt

Reputation: 534893

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>>

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.

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).

Upvotes: 1

Related Questions