Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8413923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:01:56+00:00 2026-06-10T01:01:56+00:00

I am using a UIImageView to display both still and animated images. So sometimes,

  • 0

I am using a UIImageView to display both still and animated images. So sometimes, I’m using .image and sometimes I’m using .animationImages. This is fine.

Whether it’s static or animated, I store the UIImages‘s in item.frames (see below)

The problem is that I’d like to display a UIActivityIndicatorView in the center of the view when the animation frames are loading. I would like this to happen with no images or frames in there. The line that isn’t doing what it’s supposed to is:

[self.imageView removeFromSuperview];

As a matter of fact, setting it to another image at this point doesn’t do anything either. It seems like none of the UI stuff is happening in here. BTW,

NSLog(@"%@", [NSThread isMainThread]?@"IS MAIN":@"IS NOT");

prints IS MAIN.

The image that is in there will stick around until the new animation frames are all in there (1-2 seconds) and they start animating

This is all being run from a subclass of UIView with the UIImageView as a subview.

- (void)loadItem:(StructuresItem *)item{

    self.imageView.animationImages = nil;
    self.imageView.image = nil;   

    [self.spinner startAnimating];

    self.item = item;

    if (item.frameCount.intValue ==1){
        self.imageView.image = [item.frames objectAtIndex:0];
        self.imageView.animationImages = nil;
    }else {
        [self.imageView removeFromSuperview];

        self.imageView =[[UIImageView alloc] initWithFrame:self.bounds];
        [self addSubview:self.imageView ];
        if( self.imageView.isAnimating){
            [self.imageView stopAnimating];
        }
        self.imageView.animationImages = item.frames;
        self.imageView.animationDuration = self.imageView.animationImages.count/12.0f;

        //if the image doesn't loop, freeze it at the end
        if (!item.loop){
            self.imageView.image = [self.imageView.animationImages lastObject];
            self.imageView.animationRepeatCount = 1;
        }
        [self.imageView startAnimating];
    }

    [self.spinner stopAnimating];

}

My ignorant assessment is that something isn’t being redrawn once that image is set to nil. Would love a hand.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:01:58+00:00Added an answer on June 10, 2026 at 1:01 am

    What I have found is not an answer to the question, but rather a much better approach to the problem. Simply, use NSTimer instead of animationImages. It loads much faster, doesn’t exhaust memory and is simpler code. yay!

    Do this:

    -(void)stepFrame{
        self.currentFrameIndex =   (self.currentFrameIndex + 1) % self.item.frames.count;
        self.imageView.image = [self.item.frames objectAtIndex:self.currentFrameIndex];
    }
    

    and this

    -(void)run{
        if (self.item.frameCount.intValue>1){
            self.imageView.image = [self.item.frames objectAtIndex:self.currentFrameIndex];
            self.timer = [NSTimer scheduledTimerWithTimeInterval:1/24.0f target:self selector:@selector(stepFrame) userInfo:nil repeats:YES];
        }else{
            self.imageView.image = [self.item.frames objectAtIndex:0];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to display image in UIImageView which is on the UIScrollView and using
Ii'm using this NSURL code to display an image. what I want to do
I'm using this to display a image randomly on the iPhone screen. -(IBAction)gunshot {
I am Using UIImageView in UIScrollView to display Image gallery. Here is my Code
I'm using this code to display random images on the screen. - (void) touchesBegan:(NSSet
I have an app that will show some images using UIImageView, now I want
I am using an UIImageView to load an image with aspectfit. Hence the image
Iam developing one application.In that iam using one uiimageview.And take another image view and
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I'm using UIImageView's animationImages to show some frames over a second. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.