uiview 애니메이션 didendselector : 메소드가 호출되지 않습니까?
문제
시야로 이동하는 uiview가 있습니다. 2 초 후에는 UIView를 다시 시야로 옮기고 싶습니다. 어떻게해야합니까? 나는 아래를 시도했지만 작동하지 않습니다 :(
NSLOG를 설정했지만 마무리하는 것처럼 보이지는 않습니다. loadingViewDisappear:
방법 :(
고맙습니다.
...
[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];
}
}
해결책
애니메이션 대의원을 설정해야합니다.
[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];
제휴하지 않습니다 StackOverflow