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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:56:09+00:00 2026-06-07T16:56:09+00:00

I have an image view that has two animation images, occuring in 1-second intervals.

  • 0

I have an image view that has two animation images, occuring in 1-second intervals. I want to run some methods when my image view is displaying one of those two images

I already tried doing:

if(self.imageViewThatPerformsAnimation.image == [UIImage imageNamed: @"someImage"])
    [self doSomeMethod];

but when I tried this and ran it, [self doSomeMethod]; always ran, and not just when the image view was displaying that one image.

I’m thinking about having a timer that changes a boolean value every one second then saying

if (booleanValue==YES)
    [self doSomeMethod]

It’s just that I feel there may be a better way.

  • 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-07T16:56:11+00:00Added an answer on June 7, 2026 at 4:56 pm

    If you wanted to use a NSTimer, it might look like:

    @interface MyViewController ()
    {
        NSTimer *_timer;
        NSArray *_images;
        NSInteger _currentImageIndex;
    }
    @end
    
    @implementation MyViewController
    
    @synthesize imageview = _imageview;
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        _images = [NSArray arrayWithObjects:
                   [UIImage imageNamed:@"imgres-1.jpg"], 
                   [UIImage imageNamed:@"imgres-2.jpg"], 
                   [UIImage imageNamed:@"imgres-3.jpg"], 
                   [UIImage imageNamed:@"imgres-4.jpg"], 
                   nil];
    
        _currentImageIndex = -1;
        [self changeImage];
    
        // Do any additional setup after loading the view.
    }
    
    - (void)changeImage
    {
        _currentImageIndex++;
    
        if (_currentImageIndex >= [_images count])
            _currentImageIndex = 0;
    
        self.imageview.image = [_images objectAtIndex:_currentImageIndex];
    
        if (_currentImageIndex == 0)
            [self doSomething];
    }
    
    - (void)startTimer
    {
        if (_timer) {
            [_timer invalidate];
            _timer = nil;
        }
    
        _timer = [NSTimer timerWithTimeInterval:1.0
                                         target:self 
                                       selector:@selector(changeImage)
                                       userInfo:nil
                                        repeats:YES];
    
        [[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSDefaultRunLoopMode];
    }
    
    - (void)stopTimer
    {
        [_timer invalidate];
        _timer = nil;
    }
    
    - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
    
        [self startTimer];
    }
    
    - (void)viewDidDisappear:(BOOL)animated
    {
        [super viewDidDisappear:animated];
    
        [self stopTimer];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view that has multiple views inside it, and an image presentation
I have a ImageView and draw some things on that view. Now I want
I have a ListView that has one image and two lines of texts for
In an iPhone application I'm developing I have a Image View that displays eyes
I am using a webview and on that web view i have a image.
I have a view that will be displaying downloaded images and text. I'd like
I have a view helper that manages generating thumbnails for images. The images are
I have a universal iOS app with a custom view that has three buttons,
I'm building a custom view inside of Interface Builder that has buttons with image
I have a two phase animation including a div full of images and to

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.