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 4587870
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:50:31+00:00 2026-05-21T21:50:31+00:00

I am doing some testing to try to come up with the best way

  • 0

I am doing some testing to try to come up with the best way to add small animations to a UIImageView.

The following code is working however when called for the first time there is a delay where I am guessing the animation is loading. How should I load the animation to avoid this delay? When called for a second time it starts instantly. This code is in the -(void)loadView method and [animation startAnimating]; is called from a custom method. Note: UIImageView *animation is actually a instance var.

NSString *imageName;
NSMutableArray *animImages = [[NSMutableArray alloc]init];

for(int i = 0; i <= 40; i++) {
    imageName = [NSString stringWithFormat:@"frame_%d.png", i];
    [animImages addObject:[UIImage imageNamed:imageName]];
}

UIImageView *animation; // is actually an instant var declared in header.

animation = [[UIImageView alloc]initWithFrame:CGRectMake(50, 0, 600, 300)];
animation.animationImages = animImages;
animation.animationDuration = 2;
animation.animationRepeatCount = 1;

I need to have several animations on the same UIView so I would also like to know if this is the best way to add multiple animations on a view and the correct way to manage the memory in this method.

Many thanks

  • 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-05-21T21:50:32+00:00Added an answer on May 21, 2026 at 9:50 pm

    Prefer to load resources in viewDidLoad and not loadView. You should trash them in viewDidUnload, loading in viewDidLoad will get them back should your view load again.

    One could argue that you could also trash them in didReceiveMemoryWarning, but AFAIK viewDidUnload should be used to release UI elements. If you use didReceiveMemoryWarning you can check if viewDidLoad will be called again by releasing only if viewDidUnload got called:

    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        if (![self isViewLoaded]) {
            // release resources
        }
    }
    

    But if animation is the instance var and you are really doing this

    UIImageView *animation = [[UIImageView alloc]initWithFrame:CGRectMake(50, 0, 600, 300)];
    

    you are not setting the intance variable but a local.

    Later

    As to the delay: loading 40 images needs its time no matter what you do. If you don’t want the delay in the UI load them in the background and notify UI when it is done. In this time you can show something that draws the attentions off the delay.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been doing some testing with the following code to try and work
I'm doing some unit testing, and some of the code is checking to see
I was working with quality yesterday doing some formal testing. In their procedure they
What is the best way for unit testing code paths involving a failed malloc()
I was doing some unit testing on code that could throw a number of
I was doing some testing and straight LINQ-to-SQL queries run at least 80% faster
I'm currently doing some GUI testing on a ASP.net 2.0 application. The RDBMS is
I've been doing some performance testing around the use of System.Diagnostics.Debug, and it seems
I'm a doing some blackbox testing of a ASP.Net website and I need to
I am doing some initial testing for a Rails app which will be deployed

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.