2012-04-02 140 views
0

我的animationDidStop方法没有被调用,出于某种原因,最初我以为是因为代理没有设置,但补救说,我仍然有同样的问题。有任何想法吗?在此先感谢:)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 

} 
+0

尝试移动'setAnimationDelegate'和''setAnimationDidStopSelector' ... beginAnimations'不知道这是否会帮助和目前无法测试,但这将是第一次尝试... – 2012-04-02 15:21:36

回答

1

你可以实现你想要的使用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 
       }]; 
+0

干杯工作出色,我一直推迟使用更新的符号一段时间了。 – Octave1 2012-04-02 15:45:50