2009-07-29 23 views
7

Mam UIView, który jest przeniesiony do widoku. Po 2 sekundach chciałbym ponownie przenieść UIView z widoku. Jak mam to zrobic? Próbowałem poniżej, ale to nie działa :(UIView animation didEndSelector: metoda nie jest wywoływana?

I skonfigurowaliśmy NSLog, ale nie wygląda na to wykończenie, a następnie wywołanie metody loadingViewDisappear: :(

dziękuję.

... 
    [UIView beginAnimations:@"AnimateIn" context:nil]; 
    [UIView setAnimationCurve: UIViewAnimationCurveEaseOut]; 
    [UIView setAnimationDuration: 0.7f]; 
    [UIView setAnimationDidStopSelector:@selector(loadingViewDisappear:finished:context:)]; 
    loadingView.frame = CGRectMake(rect.origin.x, rect.origin.y - 80, rect.size.width, rect.size.height); 
    [UIView commitAnimations]; 
} 

- (void)loadingViewDisappear:(NSString *)animationID finished:(NSNumber *) finished context:(void *) context { 
    NSLog((finished ? @"YES!" : @"NO!")); 
    if ([animationID isEqualToString:@"AnimateIn"] && finished) { 
     [UIView beginAnimations:@"AnimateOut" context:nil]; 
     [UIView setAnimationCurve: UIViewAnimationCurveEaseIn]; 
     [UIView setAnimationDelay:2.0f]; 
     [UIView setAnimationDuration: 0.7f]; 
     loadingView.frame = CGRectMake(0, 480, 320, 80); 
     [UIView commitAnimations]; 
     [loadingView removeFromSuperview]; 
    } 
} 

Odpowiedz

13

Musisz ustawić delegata animacja:

[UIView beginAnimations:@"AnimateIn" context:nil]; 
[UIView setAnimationCurve: UIViewAnimationCurveEaseOut]; 
[UIView setAnimationDuration: 0.7f]; 

//Add this 
[UIView setAnimationDelegate:self]; 

[UIView setAnimationDidStopSelector:@selector(loadingViewDisappear:finished:context:)]; 
loadingView.frame = CGRectMake(rect.origin.x, rect.origin.y - 80, rect.size.width, rect.size.height); 
[UIView commitAnimations]; 
Powiązane problemy