0

My animationDidStop method is not being called for some reason, initially I thought it was because the delegate was not set but having remedied that I'm still having the same problem. Any ideas? thanks in advance :)

- (void)hideInterfaceButtonClicked : (id) sender
{

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop)];

[UIView beginAnimations:@"MoveView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.5];

// Move to the right
CGAffineTransform translateInterface = CGAffineTransformMakeTranslation(454,288);
// Scale
CGAffineTransform scale = CGAffineTransformMakeScale(0.20,0.20);   

// Apply them to the view
self.transform = CGAffineTransformConcat(scale, translateInterface);

self.alpha = 0.0;

[UIView commitAnimations];

}

- (void)animationDidStop {

NSLog(@"Animation Has Stopped");
[[NSNotificationCenter defaultCenter] postNotificationName:@"hiddenInteraceViewNeeded" object:self]; //after MoveView finishes

}
Octave1
  • 525
  • 4
  • 19
  • Try moving `setAnimationDelegate` and `setAnimationDidStopSelector` `beginAnimations`... not sure if this will help and can't test this at the moment but it would be the first thing to try... – Rok Jarc Apr 02 '12 at 15:21

1 Answers1

1

You could achieve what you want by using the new (iOS4+) block syntax:

[UIView animateWithDuration:0.5
                      delay:0.0
                    options:UIViewAnimationCurveEaseIn
                 animations:^{
                     // Move to the right
                     CGAffineTransform translateInterface = CGAffineTransformMakeTranslation(454,288);
                     // Scale
                     CGAffineTransform scale = CGAffineTransformMakeScale(0.20,0.20);   

                     // Apply them to the view
                     self.transform = CGAffineTransformConcat(scale, translateInterface);

                     self.alpha = 0.0;
                 } completion:^(BOOL finished) {
                     NSLog(@"Animation Has Stopped");
                     [[NSNotificationCenter defaultCenter] postNotificationName:@"hiddenInteraceViewNeeded" object:self]; //after MoveView finishes
                 }];
tim
  • 1,682
  • 10
  • 18
  • Cheers worked wonderfully, I've been putting off using the more up-to-date notation for a while now. – Octave1 Apr 02 '12 at 15:45