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

  • Home
  • SEARCH
  • 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 9045663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:24:14+00:00 2026-06-16T11:24:14+00:00

I’m new to Objective C and X-code and I’m having trouble getting my UIImageView

  • 0

I’m new to Objective C and X-code and I’m having trouble getting my UIImageView animation to stay on screen for at least one complete cycle. I am using it as a custom wait animation for when a button is tapped and a bunch of saving and processing stuff happens. I perform those actions in a separate thread using NSOpearationQueue. Here’s the first part of my code:

My animation is defined in ViewDidLoad and it’s called ‘myAnimation’. it’s a UIImageView animation made from an array of UIImages. I set it hidden immediately and show it when I need to.

-(void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

    NSArray *myAnimationArray  = [[NSArray alloc] initWithObjects:
                        [UIImage imageNamed:@"arisprite_0000.png"],
                        [UIImage imageNamed:@"arisprite_0001.png"],
                        [UIImage imageNamed:@"arisprite_0002.png"],
                        [UIImage imageNamed:@"arisprite_0003.png"],
                        [UIImage imageNamed:@"arisprite_0004.png"],
                        [UIImage imageNamed:@"arisprite_0005.png"],
                        [UIImage imageNamed:@"arisprite_0006.png"],
                        [UIImage imageNamed:@"arisprite_0007.png"],
                        [UIImage imageNamed:@"arisprite_0008.png"],
                        [UIImage imageNamed:@"arisprite_0009.png"],
                        [UIImage imageNamed:@"arisprite_0010.png"],
                        [UIImage imageNamed:@"arisprite_0011.png"],
                        [UIImage imageNamed:@"arisprite_0012.png"],
                        [UIImage imageNamed:@"arisprite_0013.png"],
                        [UIImage imageNamed:@"arisprite_0014.png"],
                        [UIImage imageNamed:@"arisprite_0015.png"],
                        [UIImage imageNamed:@"arisprite_0016.png"],
                        [UIImage imageNamed:@"arisprite_0017.png"],
                        [UIImage imageNamed:@"arisprite_0018.png"],
                        [UIImage imageNamed:@"arisprite_0019.png"],
                        [UIImage imageNamed:@"arisprite_0020.png"],
                        [UIImage imageNamed:@"arisprite_0021.png"],
                        [UIImage imageNamed:@"arisprite_0022.png"],
                        [UIImage imageNamed:@"arisprite_0023.png"],
                        [UIImage imageNamed:@"arisprite_0024.png"],
                        [UIImage imageNamed:@"arisprite_0025.png"],
                        [UIImage imageNamed:@"arisprite_0026.png"],
                        [UIImage imageNamed:@"arisprite_0027.png"],
                        [UIImage imageNamed:@"arisprite_0028.png"],
                        [UIImage imageNamed:@"arisprite_0029.png"],
                        [UIImage imageNamed:@"arisprite_0030.png"],
                        [UIImage imageNamed:@"arisprite_0031.png"],
                        [UIImage imageNamed:@"arisprite_0032.png"],
                        [UIImage imageNamed:@"arisprite_0033.png"],
                        [UIImage imageNamed:@"arisprite_0034.png"],
                        [UIImage imageNamed:@"arisprite_0035.png"],
                        [UIImage imageNamed:@"arisprite_0036.png"],
                        [UIImage imageNamed:@"arisprite_0037.png"],
                               nil];


myAnimation.animationImages = myAnimationArray;
myAnimation.animationDuration = 2.5;
    [myAnimation.layer setBorderColor:[[UIColor blackColor] CGColor]];
    [myAnimation.layer setBorderWidth:2.0];

[self.view addSubview:myAnimation];
    [myAnimation setHidden:YES];
...
...
...
}

-(IBAction)saveToYYY:(id)sender
{
// hide current view and show save screen
[self showAnimatedSaveScreen];

// show the saving screen
[self.view bringSubviewToFront:savingBackgroundView];
[self.view bringSubviewToFront:savingText];
[self.view bringSubviewToFront:myAnimation];


/* Operation Queue init */
NSOperationQueue *queue = [NSOperationQueue new];

/* Create our NSInvocationOperation to call save code, passing in nil */
NSInvocationOperation *saveToYYYOperation = [[NSInvocationOperation alloc]
                                    initWithTarget:self
                                    selector:@selector(saveToYYYWithOperation)
                                    object:nil];

NSInvocationOperation *saveToXXXOperation = [[NSInvocationOperation alloc]
                                                  initWithTarget:self
                                                       selector:@selector(saveToXXXWithOperation)
                                                  object:nil];

/* Add the operation to the queue */
[saveToXXXOperation addDependency:saveToYYYOperation];
[queue addOperation:saveToYYYOperation];
[queue addOperation:saveToXXXOperation];    
}

then, in my last queue operation i have

-(void)saveToXXXWithOperation
{
... 
a bunch of processing
...

[self performSelectorOnMainThread:@selector(hideAnimatedSaveScreen) withObject:nil     waitUntilDone:YES];
}

Everything seems to be working fine, except that when these save operations are too fast, especially on iPads, myAnimation doesn’t get to finish it’s duration of 2.5. I’d like to play at least once before I hide my animation. Is there a way to implement this?

  • 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-16T11:24:15+00:00Added an answer on June 16, 2026 at 11:24 am

    If the question is “how can I wait 2.5 seconds after I finish saving”, simply have your hideAnimatedSaveScreen implementation use delayed performance (performSelector:withObject:afterDelay:). You can use timestamps ([NSDate date]) to vary that amount, learning how much time has actually elapsed since the animation started and subtracting, as desired.

    If the question is “how can I know when my animation is done”, that’s hard to say, since you don’t actually show any animation in your code, so it’s impossible to guess what you mean when you say you’ve got a UIImageView animation.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm making a simple page using Google Maps API 3. My first. One marker

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.