2009-07-29 29 views
7

Tôi có UIView được chuyển thành chế độ xem. Sau 2 giây, tôi muốn di chuyển UIView ra khỏi tầm nhìn lần nữa. Làm thế nào để tôi làm điều này? Tôi đã cố gắng bên dưới, nhưng nó không hoạt động :(Hoạt ảnh UIView đã làmEndSelector: phương pháp không được gọi?

tôi đã thiết lập các NSLog, nhưng nó không giống như nó kết thúc và sau đó gọi phương thức loadingViewDisappear: :(

Cảm ơn bạn.

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

Trả lời

13

Bạn cần phải thiết lập các đại biểu hoạt hình:

[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]; 
Các vấn đề liên quan