views:

32

answers:

1

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's website just says

- (BOOL)isAnimating

and that it returns a Boolean YES or NO.

but how do you use this?

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?

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

or is it like:

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

or am i just getting the whole concept entirely wrong?

A: 

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
}
notme
I couldn't get it to work but it seems like a good approach so thanks anyway.
are these methods, that i need to call elsewhere for them to do anything? if so how? I heard it should be like [object method]; but these apply to more than one object so how do i implement them?
What do you mean? You must implement the 2 objects (yourLoadingAnimation and yourImageView)
notme