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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:04:17+00:00 2026-05-21T09:04:17+00:00

How I can stop animation on the last frame. Code here: – (void)method{ NSMutableArray

  • 0

How I can stop animation on the last frame.
Code here:

- (void)method{

NSMutableArray *images = [[NSMutableArray alloc]init];
NSInteger i;
for (i = 0; i < 75; i++){ 

    NSString *str = [NSString stringWithFormat:@"pictures%i.png", i];
    UIImage *img =[UIImage imageNamed:str];
    [images addObject:img];

}
// Begin the animation
somePicture = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"8Ball_003_00075.png"]];
//somePicture = [[[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)] autorelease];
//[somePicture isAnimating]==0;
somePicture.frame = CGRectMake(0, 0, 320, 480);
[somePicture setAnimationImages:images];
somePicture.animationDuration = 5.0f;
somePicture.animationRepeatCount = 1;
[somePicture startAnimating];
somePicture.center = CGPointMake(160.0f, 230.0f);

//[images release];
[NSTimer scheduledTimerWithTimeInterval: 0.5f target: self selector: @selector(tick) userInfo: nil repeats: YES];

[self.view addSubview:somePicture];

}

-(void)tick{

if(![somePicture isAnimating]) { [timer invalidate]; [somePicture stopAnimating]; timer=nil; NSLog(@"@ye1111eah!!!");}
else
NSLog(@"@y");}


I know that I must used NSTimer but i don’t know how 🙁

  • 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-21T09:04:18+00:00Added an answer on May 21, 2026 at 9:04 am

    Why do you allocate somePicture twice

    somePicture = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"8Ball_003_00075.png"]];
    somePicture = [[[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)] autorelease];
    

    Can’t you just use this

    somePicture = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"8Ball_003_00075.png"]];
    somePicture.frame = CGRectMake(0.0f, 0.0f, 320.0f, 480.0f);
    

    UPDATE

    I think this will do it

        - (void)method{
    
        NSMutableArray *images = [[NSMutableArray alloc]init];
        NSInteger i;
        for (i = 0; i < 75; i++){ 
    
            NSString *str = [NSString stringWithFormat:@"pictures%i.png", i];
            UIImage *img =[UIImage imageNamed:str];
            [images addObject:img];
    
        }
        // Begin the animation
        somePicture = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"8Ball_003_00075.png"]];
        somePicture.frame = CGRectMake(0.0f, 0.0f, 320.0f, 480.0f);
        self.view addSubview:somePicture];
        //[somePicture isAnimating]==0;
        [somePicture setAnimationImages:images];
        somePicture.animationDuration = 5.0f;
        somePicture.animationRepeatCount = 1;
        somePicture.center = CGPointMake(160.0f, 230.0f);
        [somePicture startAnimating];
     [self performSelector:@selector(tick) withObject:self afterDelay:5.0];
    
        }
    - (void)tick
    {
    [somePicture stopAnimating];
    if(![somePicture isAnimating]) 
    { 
        NSLog(@"@ye1111eah!!!");
    }
    else
    NSLog(@"@y");
    }
    

    hope this helps

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

Sidebar

Related Questions

Is there any method so that I can stop syncing to gmail. I want
How to stop an animation so it won't produce Completed event. Here's simple example
I'm using UIView class method animateWithDuration for repeating my view animation. How can I
How can I start and stop image animation using button control? imageView.animationImages = [NSArray
Is there a way I can stop all processes in a certain directory through
I have looked and tried but don't see where I can stop some being
I'm trying to write a program that can stop and start services using SilverLight
How can I stop a background thread on keyboard flip in android?
How can I stop a build, and notify the user if a file does
How can I stop the ABAP extended program check (SLIN) from reporting errors in

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.