2011-02-03 2 views

ответ

13

Это простое пространство. Вы должны определить метод, как

-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 
//do smth 
} 

Тогда просто позвоните

[UIView beginAnimations: nil context: nil]; 
[UIView setAnimationDelegate: self]; //or some other object that has necessary method 
[UIView setAnimationDidStopSelector: @selector(animationDidStop:finished:context:)]; 

Вы можете оставить мнение, что вы хотите удалить. Для этого вам нужно сделать, это:

[UIView beginAnimations: nil context: someView]; 

, а затем добавить в обратного вызова:

-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 
     [(UIView*)context removeFromSuperView]; 
    } 
+0

Является ли селектор взаимозаменяемым? – Jumhyn

+0

Что вы имеете в виду? – Max

+0

Я просто установил цель в качестве представления, а затем селектор «removeFromSuperView» – Jumhyn

0

Я сделал это для лейбла я хотел сделать флип. Он запускает анимацию, но затем хочет начать работу после первого завершения. Для вашего вопроса, вместо запуска другой анимации, вы можете просто освободить и освободить все, что больше не нужно.

- (void) doIt { 
    CGRect r = self.bounds; 

    // Save some context information for after the animation 
    struct contextStruct *c; 
    c = (struct contextStruct *) malloc(sizeof(struct contextStruct)); 
    c->oldHeight = r.size.height; 

    [UILabelThatFlips beginAnimations: @"flipMe" context: c]; 
    [UILabelThatFlips setAnimationDelegate: self]; 
    [UILabelThatFlips setAnimationDidStopSelector: @selector(animationDidStop:finished:context:)]; 
    [UILabelThatFlips setAnimationDuration: 0.3]; 
    [UILabelThatFlips setAnimationCurve: UIViewAnimationCurveEaseIn]; 
    if(animation == UILabelAsButtonAnimationFlip) { 
    r.size.height = 0.0; 
    self.bounds = r; 
    [UILabelThatFlips commitAnimations]; 
} 

- (void) animationDidStop: (NSString *) animationID finished: (NSNumber *) finished context: (void *) context { 
    struct contextStruct *c = context; 
    CGRect r = self.bounds; 

    [UILabelThatFlips beginAnimations: @"flipBack" context: NULL]; 
    [UILabelThatFlips setAnimationDelay: 0.08]; 
    [UILabelThatFlips setAnimationDuration: 0.3]; 
    [UILabelThatFlips setAnimationCurve: UIViewAnimationCurveEaseOut]; 
    r.size.height = c->oldHeight; 
    self.bounds = r; 
    [UILabelThatFlips commitAnimations]; 

    // Stop up any memory leaks 
    free(context); 
}