Search code examples
iosuiviewanimatewithduration

UIViewAnimateWithDuration completion never called


I am using the UIView animateWithDuration:delay:options:animations:completion: method but the completion method is never getting called. Here is my code:

[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^
             {
                 //random lines of code

             }completion:^(BOOL finished){
                 if (finished)
                 {
                     NSLog(@"FINISHED");
                 }
             }];

EDIT: When I comment out the lines in my animations: it gets called???!!!

These are the lines:

CGFloat objectY = object.frame.origin.y;
objectY += speed;
object.frame = CGRectMake(object.frame.origin.x, objectY, 75, 75);

Solution

  • I am taking a guess - you want to animate the movement of a continuous gesture? If yes, the animation never ends due the user interaction.

    Just update the frame, no UIView Animation. Should work just fine.