0

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?

lavelle
  • 1,446
  • 1
  • 17
  • 30
  • This question feels like it's missing an introductory paragraph. Perhaps you can rephrase it to state exactly (A) what your problem is, (B) what you've tried already, (C) how it didn't work. Are you maybe talking about the `isAnimating` method in `UIActivityIndicatorView` or `UIImageView`? – Shaggy Frog Oct 24 '10 at 21:16
  • you're right, i rushed it. I'm talking about the UIImageView one. – lavelle Oct 24 '10 at 21:41

1 Answers1

1

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
}
pasine
  • 11,311
  • 10
  • 49
  • 81
  • I couldn't get it to work but it seems like a good approach so thanks anyway. – lavelle Oct 25 '10 at 08:16
  • 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? – lavelle Oct 25 '10 at 08:20
  • What do you mean? You must implement the 2 objects (yourLoadingAnimation and yourImageView) – pasine Oct 25 '10 at 09:38