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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:01:10+00:00 2026-05-26T15:01:10+00:00

I am trying to add animation for UIImages which are added in an array.

  • 0

I am trying to add animation for UIImages which are added in an array. I would like to add animation to array index 0 and make it animated.I want to change the imageCount and animate it every 3 secs. I have also added NSTimer which will help me to change the image but it is not changing the image correctly. I have like a menu list in which the first link should be animated. Has anyone come across such an issue before and can help me out.

- (void)viewDidLoad {
[super viewDidLoad];
[NSTimer scheduledTimerWithTimeInterval:3 
                                 target:self 
                               selector:@selector(animateFunction) 
                               userInfo:nil 
                                repeats:YES];
[self setListArray:[NSMutableArray arrayWithObjects:@"",@"List",@"To-Do",nil]];

}

 -(void)animateFunction
   {
NSLog(@"Timer heartbeat %i",imageCount);
if (imageCount == 2) {
    // set the image count back to initial value;
    imageCount = 1;
} else {
    imageCount++;
}

[self setCellIconNames:[NSArray arrayWithObjects:[NSString stringWithFormat:@"image%i.png", imageCount],@"final.png",@"blue.png",nil]];
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

NSUInteger row = [indexPath row];


NSString *cellIconName = [[self cellIconNames] objectAtIndex:[indexPath row]];

UIImage *cellIcon = [UIImage imageNamed:cellIconName];
[[cell imageView] setImage:cellIcon];

cell.textLabel.text = [listArray objectAtIndex:row];
cell.backgroundColor = [UIColor clearColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;
}
  • 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-26T15:01:11+00:00Added an answer on May 26, 2026 at 3:01 pm

    I believe the problem is that imageCount is being set to 1 each time you call the method associated with the timer. Try declaring imageCount in the header file as something like int imageCount;, remove imageCount = 1; from the animateFunction method and place it in the viewDidLoad or some similar method to initialize it. Then when you iterate imageCount (which you can substitute imageCount = imageCount + 1 with just imageCount++ if you like), it will add 1 to the variable properly instead of returning 2 each time (which is what the current method does). If you need the images to loop, you will need to set up a check that resets the imageCount like the following:

    if (imageCount == yourMaxNumber) {
        // set the image count back to initial value;
        imageCount = 1;
    } else {
        imageCount++;
    }
    

    Hopefully that does the trick for you

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

Sidebar

Related Questions

I am trying to add one UIView with a transition style zoom animation like
I am trying to built an animated circle which would be drawn clockwise until
Created a simple jquery-nivo-like slider using wpf and want to add an animation between
I'm trying to add an animation to my TabActivty. For example, when the user
I'm trying to add an animation to my ListView so text will fade into
I'm trying to add a swipe animation to an element. I've tried initializing jqTouch
I am trying to add a bounce effect to my animation but am having
I'm trying to figure out a nice way to add a busy animation to
I'm trying to create a button which displays animated images. I read in this
I am trying to add a little animation with jQuery to my navigation bar.

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.