gpt4 book ai didi

iphone - UIView动画didEndSelector : method not getting called?

转载 作者:行者123 更新时间:2023-12-03 18:38:27 25 4
gpt4 key购买 nike

我有一个已移入 View 的 UIView。 2 秒后,我想再次将 UIView 移出 View 。我该怎么做呢?我已经尝试过以下方法,但它不起作用:(

我已经设置了 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];
}
}

最佳答案

您需要设置动画委托(delegate):

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

关于iphone - UIView动画didEndSelector : method not getting called?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1200122/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com