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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:12:36+00:00 2026-06-13T05:12:36+00:00

I have a simple viewController. The View controller use animation. If I am displaying

  • 0

I have a simple viewController. The View controller use animation. If I am displaying list, it will animate to map. At that time it will also change the button that points to map to point to list instead.

So by keep pressing the same button (it’s 2 different button actually, but users see that as the same button), user can keep switching from map to list and via versa.

Works fine. With some catch.

What about if users tap too fast? Let’s just say that canning or punishing them is not an option given that I want my application to indeed be used.

This is the current program:

-(void) transitiontoViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL))completion1
{


    [self enableButtonWithBool:false];
    UIViewController * fromController = self.last2ViewsInTheContainer.lastObject;
    if (fromController.view.superview!= self.ContainerView)
    {
        return;
    }
    [self transitionFromViewController:fromController toViewController:toViewController duration:duration options:options animations:animations completion:^(BOOL finished) {
        if (completion1 == Nil) //can't execute nil block. can be more elegantly done with [completion1 invoke] if there is such function. Anyway, do nothing if completion1 is nil
        {

        }
        else
        {
            completion1 (finished);
        }
        [self.last2ViewsInTheContainer addObject:toViewController];

        if (self.last2ViewsInTheContainer.count>2)
        {
            [self.last2ViewsInTheContainer removeObjectAtIndex:0];
        }
    }];

    [self enableButtonWithBool:true];
    [self ReloadorRedraw];
}

Simple transition. I just want to point out at the end of the function 2 controllers view have the same subview. It looks like the transition is not yet complete at the end of the function. The old view controller is not really removed, etc.

The content of ReloadorRedraw is the following:

-(void)ReloadorRedraw;
{
    BGCRBadgerStandardViewViewController * listOrMap = nil;
    if ([self.last2ViewsInTheContainer lastObject]==self.filterController)
    {
        [self.changeFilterButton setBackgroundImage:[UIImage imageNamed:filterBarOpenImageString] forState:UIControlStateNormal];
        listOrMap = self.last2ViewsInTheContainer[0];
    }
    else
    {
        [self.changeFilterButton setBackgroundImage:[UIImage imageNamed:filterBarCloseImageString] forState:UIControlStateNormal];
        listOrMap = self.last2ViewsInTheContainer.lastObject;
    }

    if (listOrMap==self.listBusinessViewController)
    {
        self.navigationItem.rightBarButtonItem=self.mapButton;
    }
    else
    {
        self.navigationItem.rightBarButtonItem=self.listButton;
    }
}

If I clicked too fast, I got this message:
Unbalanced calls to begin/end appearance transitions for .
Unbalanced calls to begin/end appearance transitions for .

after which the app is in an invalid state.

One way to remedy the situation is to “disable” button until animation finish.

-(void) transitiontoViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL))completion1
{


    [self enableButtonWithBool:false];
    UIViewController * fromController = self.last2ViewsInTheContainer.lastObject;
    if (fromController.view.superview!= self.ContainerView)
    {
        return;
    }
    [self transitionFromViewController:fromController toViewController:toViewController duration:duration options:options animations:animations completion:^(BOOL finished) {
        if (completion1 == Nil) //can't execute nil block. can be more elegantly done with [completion1 invoke] if there is such function. Anyway, do nothing if completion1 is nil
        {

        }
        else
        {
            completion1 (finished);
        }
        [self.last2ViewsInTheContainer addObject:toViewController];

        if (self.last2ViewsInTheContainer.count>2)
        {
            [self.last2ViewsInTheContainer removeObjectAtIndex:0];
        }

    [self enableButtonWithBool:true];
    [self ReloadorRedraw];
    }];

}

Basically I am moving

    [self enableButtonWithBool:true];
    [self ReloadorRedraw];

to the completion block.

the function enableButtonWithBool is this simple function:

-(void)enableButtonWithBool: (BOOL) enable
{
    self.mapButton.enabled=enable;
    self.listButton.enabled= enable;
    self.changeFilterButton.enabled =enable;
    self.searchBar.enabled =enable;
}

This works well.

My partner doesn’t like it. That’s because disabled button looks ugly even though only for .3 seconds. Users won’t like it even though it’s for their own good.

So basically I got to enable reenable the button quickly rather than wait till application is ended.

But how to do that and still make a robust application that can withstand users’ rapid clicking?

I think it would help if someone can also explain when exactly the “real” transition complete. I mean the actual remove from superview of old stuff and add to subview the new stuff. Is the animation just a “movie” that doesn’t really change transition or view structure?

  • 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-13T05:12:38+00:00Added an answer on June 13, 2026 at 5:12 am

    Instead of actually enabling or disabling your buttons, set an internal Boolean variable to true or false. Then the code that executes when your button is pushed will check that variable to decide whether to ignore the button push or actually do something.

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

Sidebar

Related Questions

I have a very simple RootView Controller ->Detail View Controller, to display a list
NavigationControllers have ViewController stacks to manage, and limited animation transitions. Adding a view controller
I have a root view controller with just a simple navigation button that loads
I have created a simple Xcode 4.2 project with a empty view controller. I
How you can add a child ViewController into Master View Controller ? I have
I have a view controller that I want to lazily initialize, and once initialized,
I have a simple viewcontroller with labels and text boxes. but to many to
I have simple php validation form that is halfway working. If you leave the
I have simple win service, that executes few tasks periodically. How should I pass
I have a fairly simple iPhone application that I want to have run on

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.