AnimationDidStop не вызывается - PullRequest
       16

AnimationDidStop не вызывается

0 голосов
/ 02 апреля 2012

Мой метод animationDidStop по какой-то причине не вызывается, изначально я думал, что это потому, что делегат не был установлен, но исправил, что у меня все еще остается та же проблема. Есть идеи? заранее спасибо :)

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

}

1 Ответ

1 голос
/ 02 апреля 2012

Вы можете достичь желаемого, используя новый (iOS4 +) синтаксис блока :

[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
                 }];
...