-2

I am adding a ChildViewController this way, which opens half the way of screen.

   m_customStartupView = [[CustomStartUpViewController alloc]init];
        m_customStartupView.delegate = self;

        if(m_showStatus == SHOW_STATUS)
        {
             m_customStartupView.dialogToShow = LAST_SYNC_STATUS;
        }       


        [self addChildViewController:m_customStartupView];
        [[self view] addSubview:[m_customStartupView view]];
        [m_customStartupView didMoveToParentViewController:self];


        CGRect rect = m_customStartupView.view.frame;
        if(IPHONE_5)
        {
            rect.origin.y = 568;
        }

        else
        {
            rect.origin.y = 480;
        }

        m_customStartupView.view.frame = rect;

        [UIView beginAnimations:@"ShowView" context:nil];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
        [UIView setAnimationDuration:0.2];
        if(IPHONE_5)
        {       
            rect.origin.y = 520;
        }
        else
        {
            rect.origin.y = 420;
        }

        m_customStartupView.view.frame = rect;
        [UIView commitAnimations];

On dismiss of ChildView I am calling this:

-(void)dismissStartupAlertView:(BOOL)buttonClicked
{   
    CGRect rect = m_customStartupView.view.frame;
    if(IPHONE_5)
    {
        rect.origin.y =  520
    }
    else
    {
        rect.origin.y = 420 
    }
    m_customStartupView.view.frame = rect;

    [UIView beginAnimations:@"ShowView" context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.2];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
    if(IPHONE_5)
    {
        rect.origin.y = 568;
    }
    else
    {
        rect.origin.y = 480;
    }

    m_customStartupView.view.frame = rect;
    [UIView commitAnimations];
}


- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
    if([animationID isEqualToString:@"ShowView"])
    {
        [m_customStartupView willMoveToParentViewController:nil];
        [m_customStartupView.view removeFromSuperview];
        [m_customStartupView removeFromParentViewController];
    }
}

So I have two buttons, Button 1 and Button 2, when user taps button1 a childView is animated from bottom and it shows. now if user presses button 2, then the previous childView is dismissed and then the new childView is shown

So the problem is that if I tap both buttons very fast, like playing a casio, then childViews overlap.

1)How can we fix this problem.

2) Whether I am doing it correctly

Regards Ranjit

matt
  • 515,959
  • 87
  • 875
  • 1,141
Ranjit
  • 4,576
  • 11
  • 62
  • 121

1 Answers1

0

Try temporarily disabling button 2 while the animation is taking place :

   [button2 setEnabled:NO]

Then reverse this when the animation has finished :

  [button2 setEnabled:YES]
NiallJG
  • 1,881
  • 19
  • 22