动画完成后如何调用函数

发布于 2024-10-31 23:20:23 字数 1497 浏览 1 评论 0原文

[self performSelector:@selector(callFunction) withObject:nil afterDelay:0 ]

在功能上。 - (void) callFunction{

imageview = [[[UIImageView alloc] initWithFrame:CGRectMake(x,y,w,h)]autorelease];
imageview.image = [[UIImage imageNamed: [NSString stringWithString:name]]autorelease];
[self.view addSubview:imageview];
imageview.frame = CGRectMake(imageview.frame.origin.x, (imageview.frame.origin.y),    imageview.frame.size.width, imageview.frame.size.height);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
//[UIView setAnimationWillStartSelector:@selector(Transform2)];



[UIView setAnimationDuration:k_AnimateTime];

[UIView setAnimationBeginsFromCurrentState:YES];
//[UIView setAnimationDidStopSelector:@selector(increaseCount)];
imageview.frame = CGRectMake(imageview.frame.origin.x - Ex, (imageview.frame.origin.y - Ey), imageview.frame.size.width, imageview.frame.size.height);
    CGAffineTransform rotate0 = CGAffineTransformMakeRotation(0.00);
CGAffineTransform moveLeft0 = CGAffineTransformMakeTranslation(0.9,0.9);
CGAffineTransform combo10 = CGAffineTransformConcat(rotate0, moveLeft0);

CGAffineTransform zoomOut0 = CGAffineTransformMakeScale(1.1,1.1);
CGAffineTransform transform0 = CGAffineTransformConcat(zoomOut0, combo10);
imageView.transform = transform0;

[UIView commitAnimations];

[self.view addSubview:imageview];

}

如何使用 NSTimer 在 10 秒后调用函数,但转换不起作用。 请建议我如何在动画完成后调用函数。

[self performSelector:@selector(callFunction) withObject:nil afterDelay:0 ]

in function.
- (void) callFunction{

imageview = [[[UIImageView alloc] initWithFrame:CGRectMake(x,y,w,h)]autorelease];
imageview.image = [[UIImage imageNamed: [NSString stringWithString:name]]autorelease];
[self.view addSubview:imageview];
imageview.frame = CGRectMake(imageview.frame.origin.x, (imageview.frame.origin.y),    imageview.frame.size.width, imageview.frame.size.height);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
//[UIView setAnimationWillStartSelector:@selector(Transform2)];



[UIView setAnimationDuration:k_AnimateTime];

[UIView setAnimationBeginsFromCurrentState:YES];
//[UIView setAnimationDidStopSelector:@selector(increaseCount)];
imageview.frame = CGRectMake(imageview.frame.origin.x - Ex, (imageview.frame.origin.y - Ey), imageview.frame.size.width, imageview.frame.size.height);
    CGAffineTransform rotate0 = CGAffineTransformMakeRotation(0.00);
CGAffineTransform moveLeft0 = CGAffineTransformMakeTranslation(0.9,0.9);
CGAffineTransform combo10 = CGAffineTransformConcat(rotate0, moveLeft0);

CGAffineTransform zoomOut0 = CGAffineTransformMakeScale(1.1,1.1);
CGAffineTransform transform0 = CGAffineTransformConcat(zoomOut0, combo10);
imageView.transform = transform0;

[UIView commitAnimations];

[self.view addSubview:imageview];

}

How to call function after 10 second using NSTimer but transform do not work.
please suggest me how to call function after animation will complete.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千年*琉璃梦 2024-11-07 23:20:23

您可以在动画完成后启动计时器。在你的情况下你应该开始时间

[NSTimer scheduledTimerWithTimeInterval:k_AnimateTime target:self selector:@selector(yourfunction) userInfo:nil repeats:NO];

you can start timer after your animation finished. in your case you should start time as

[NSTimer scheduledTimerWithTimeInterval:k_AnimateTime target:self selector:@selector(yourfunction) userInfo:nil repeats:NO];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文