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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:21:51+00:00 2026-05-13T06:21:51+00:00

On simulation, after i load the UIView that contains 52 UIImageView; it takes at

  • 0

On simulation, after i load the UIView that contains 52 UIImageView; it takes at least 3 clicks before the animation begins. On the first 2 clicks, the touchesBegan is invoked. i know that because the NSLog(@”Just before for loop); was displayed on the console. However the console states that the cardAnimationArray is empty in the first 2 clicks.

Only after 3rd click, the animation begins. The weird thing is that, by clicking other cards (UIImageView) after 3rd click, the animation begins on 1st click (behaves as normal).

Somehow it just doesn’t step into the for loop in the first 2 clicks! why is this so???

MY code is as below:

     - (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *documentsDirectory = [paths objectAtIndex:0];
 NSString *myPathDocs =  [documentsDirectory stringByAppendingPathComponent:@"Cards.plist"];
 NSMutableArray *array = [[NSArray alloc] initWithContentsOfFile:myPathDocs];

 NSMutableDictionary *dict = [array objectAtIndex:self.tag];
 NSString *cardMoved = [dict objectForKey:@"Card"];

 NSMutableArray *cardAnimationPreloadingArray = [[NSMutableArray alloc] initWithCapacity:20];
 self.cardAnimationArray = [[NSMutableArray alloc] initWithCapacity:20];
 [cardAnimationPreloadingArray release];
 NSLog(@"Just before for loop");
 for (int k; k < 20; k++) {
  NSLog(@"counting i: %d",k);
  int j = k+1;
  cardMovedImageName = [NSString stringWithFormat:@"Animated %@%d.png",cardMoved,j];
  NSLog(@"cardMovedImageName %@ at %d",cardMovedImageName, k);
  UIImage *cardMovedImage = [UIImage imageNamed:cardMovedImageName];
  [cardAnimationArray insertObject:cardMovedImage atIndex:k];
 }

 CGRect selfFrame = self.frame;
 selfFrame.size.width = 110;
 selfFrame.size.height = 164;
 [self setFrame:selfFrame];
 [self.superview bringSubviewToFront:self];
 CGPoint pt = [[touches anyObject] locationInView:self.superview];
 self.center = pt;




  NSLog(@"cardAnimationArray %@", cardAnimationArray);
 self.clipsToBounds = NO;
 self.animationImages = [NSArray arrayWithArray:cardAnimationArray];
 [self setAnimationRepeatCount:1];
 self.animationDuration= 0.3;
 [self startAnimating];
 self.image = [UIImage imageNamed:cardMovedImageName];



}
  • 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-13T06:21:51+00:00Added an answer on May 13, 2026 at 6:21 am

    You never seem to assign a value to ‘k’ so it may never be less than 20.

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

Sidebar

Related Questions

I have an app need to load photos from simulator photo library. After I
Update III: After googling around I've found that this is not an uncommon problem.
How do you properly load the value of a predefined .byte into a register?
I am attempting to save and load a UIImage to and from the iPhone
Situation: got a list of links which should load another list (located at the
After reading the documentation (http://stw.castleproject.org/Windsor.Installers.ashx) I've found a strange part: Although technically it's OK
I am using the following to check after a page fires to see if
I will describe my problem in simple way so it's not exactly what I'm
I'm using jQuery UI tabs, loading the tab content via ajax. Content may contain
Say, we have some items, and each defines some partial sorting rules, like this:

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.