如何在iPhone应用程序中使用isAnimating [英] How to use isAnimating in an iPhone app

查看:149
本文介绍了如何在iPhone应用程序中使用isAnimating的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个由一系列静止图像制成的自定义加载菜单,该菜单循环3次,然后显示一张图片。目前,该图片从一开始就可见。我想使用isAnimating找出加载动画何时停止,并关闭 myImage.hidden ,或者使用 UIImageView 最初包含白色图像,然后在 isAnimating 返回 NO 时被图片替换。

I want to have a custom loading menu made from a series of stills, that loops 3 times and then reveals a picture. Currently the picture is visible from the start. I want to use isAnimating to find out when the loading animation has stopped, and either change myImage.hidden off, or have the UIImageView initially containing a white image, then being replaced with the picture when isAnimating returns NO.

Apple网站只是说

Apple's website just says

- (BOOL)isAnimating

并返回布尔值YES或NO。

and that it returns a Boolean YES or NO.

您使用这个吗?

我需要根据是否正在制作动画来进行操作,所以我将结果返回到变量中并检查是否存在

I need things to happen depending on whether something is animating or not, so i do i put the result it returns in a variable and check that in the conditional of an if statement?

将其放入if语句本身中是什么条件?
还是一段时间内的语句?

put it in an if statement itself? or is it a while statement?

还是这样:

- (BOOL)isAnimating{
     //stuff to do if it is
}

还是我只是把整个概念完全弄错了?

or am i just getting the whole concept entirely wrong?

推荐答案

我猜isAnimating方法只是告诉你如果UIViewImage实际上正在执行动画。

因为您只想在显示图像之前创建一个简短的加载,为什么不简单地使用计时器呢?
您可以执行以下操作

I guess isAnimating method just tells you if an UIViewImage is actually performing an animation.
Since you just want to create a short loading before displaying your image, why don't you simply use a timer? You can do something like this

- (void)startAnimation {
    yourImageView.hidden = YES; // Keep you image hidden while loading
    [yourLoadingAnimation startAnimating]; // Start you loading animation
    NSInteger timeout = 2; // Duration in seconds of your loading animation
    [NSTimer scheduledTimerWithTimeInterval:timeout target:self selector:@selector(stopAnimation) userInfo:nil repeats:NO]; // Set the timer
}

- (void)stopAnimation {
    [yourLoadingAnimation stopAnimating]; // Stop your loading animation
    yourLoadingAnimation.hidden = YES; // Hide your laading animation
    yourImageView.hidden = NO; // Display your image
}

这篇关于如何在iPhone应用程序中使用isAnimating的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆