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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:45:21+00:00 2026-06-03T00:45:21+00:00

I have an application with multiple views that transitions to the main screen depending

  • 0

I have an application with multiple views that transitions to the main screen depending on which button was pressed. My current problem is that if the view is in the middle of animating then when the user selects another button then the whole layout becomes messed up. (ex: the views don’t align with the screen meaning that they become a few pixels off)

What I would like to know is if there is a way to check if the view is currently animating and if so just have it animate to the last frame and skip anything in between. Below is a small piece of code that I have just tested based on what I have read on other user asked questions on SO:

-(IBAction)buttonPress:(id)sender
{
    if([selectedView.layer.animationKeys count] > 0)
    {
        [selectedView.layer removeAllAnimations];
    }

// Perform other calculations once the animation has stopped
}
  • 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-03T00:45:22+00:00Added an answer on June 3, 2026 at 12:45 am

    There are many ways to do this but….

    If you are using block animations you could set a “isAnimating” flag when the animation starts and set it again in the completion block. You could check the bool from anywhere and handle cases as needed.

    As for needing code to execute after an animation occurs, but

    // animation code in some method...
    [UIView animateWithDuration:1.0
        delay: 0.0
        options: UIViewAnimationOptionCurveEaseIn
        animations:^{
             isAnimating = YES;
             fooView.alpha = 0.0;
        }
        completion:^(BOOL finished){
             isAnimating = NO;
             [[NSNotificationCenter defaultCenter] postNotificationName:@"FooBeDone" object:nil userInfo:nil]
        }];
    
    -(IBAction)buttonPress:(id)sender {
        if (isAnimating) {
             [[NSNotificationCenter defaultCenter] addObserver:self 
                               selector:@selector(doBar:) 
                                   name:@"FooBeDone"
                                 object:nil];
             // possibly disable button to prevent multiple taps?
        } else {
             [self doBar];
        }
    }
    
    - (void)doBar {
         // do what needs to be done when when the animation is over
         [[NSNotificationCenter defaultCenter] removeObserver:self name:@"FooBeDone" object:nil];
         // possibly enable button again
    }
    

    edit: I added more code to show a possible notification method. Creating extended loops in your IBAction will lock the user interface until the loop finishes and you can get back to the main run loop, so it’s highly advised to avoid it. Notifications should give you the same effect but allow your main run loop to continue unhindered.

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

Sidebar

Related Questions

I have created an application with multiple views. I have my main view (ViewController.h)
I have a MVVM application that contains multiple views with some complex IsReadOnly rules
I am working on an android application that requires multiple views which will overlap
I have multiple views that come and go as the application runs. I want
I understand that view controllers help control multiple views in an application, but I
I have a navigational based application which has multiple views. Is it possible to
I have an application which will be used by multiple companies.So my views/pages are
I have an application which supports multiple types and versions of some devices. It
I have an application which runs multiple threads. I use MadExcept to catch errors
I have a growing application with multiple usercontrols, windows, etc that all send a

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.