Frage

Ich habe eine UIView, die in Sicht bewegt wird. Nach 2 Sekunden, würde Ich mag wieder die UIView aus der Sicht bewegen. Wie mache ich das? Ich habe die unten versucht, aber es funktioniert nicht: (

Ich habe Setup die NSLog, aber es sieht nicht so aus es Schlichten und dann die loadingViewDisappear: Methode aufrufen: (

Danke.

...
    [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];
    }
}
War es hilfreich?

Lösung

Sie müssen die Animation Delegierten setzen:

[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];
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top