1

UPDATE : (I redid my functions so all the animations won't be as nested as before. Still no luck)

I have a piece of code where a try to, in this order:

  1. Hide view A
  2. Show view B
  3. Show view C

The order is important!

The code is the following :

Main function:

        [fileMenuController hide:0.2 andDelay:0.1]; 
        [drawingToolController show:0.2 andDelay:0.2];
        [penSizeMenuController showSubViewWithDuration:0.4];

fileMenuController hide function:

     [UIView animateWithDuration:duration //begin animation
                          delay:delay 
                        options:UIViewAnimationCurveEaseIn 
                     animations:^{
                         [self.view setFrame:CGRectOffset([self.view frame], 0, -self.view.frame.size.height)];             
                     } 
                     completion:nil
     ];

drawingToolController show function:

    [UIView animateWithDuration:duration //begin animation
                          delay:delay
                        options:UIViewAnimationCurveEaseIn 
                     animations:^{
                         [self.view setFrame:CGRectOffset([self.view frame], 0, self.view.frame.size.height)];             
                     } 
                     completion:nil
     ];

penSizeController show function:

    [UIView transitionWithView:self.view 
                  duration:duration
                   options:UIViewAnimationOptionTransitionCurlDown
                animations:^{ [self.view addSubview:subView] ;}
                completion:nil];
self.view.alpha = 1;

My problem is the block penSizeController showSubView starts with the first animation (fileMenuController hide)!

The first two animations (fileMenuController hide and drawingToolController show) are working properly. When fileMenuController hide is done, drawingToolController starts.

So, does somebody know why the part in the penSizeController showSubView block starts at the same time as the first animation?

peterphonic
  • 1,013
  • 1
  • 16
  • 34
  • So you want to show view c after the other two complete? It's starting immediately because you have no delay set on that animation. Set the delay to 0.4 and it will start after the other two. – Jason Harwig Oct 05 '11 at 18:11
  • @JasonHarwig This has been resolved there : http://stackoverflow.com/questions/7655774/how-to-use-animationwithduration-and-transitionwithview-altogether – peterphonic Oct 06 '11 at 16:51

1 Answers1

0

I'd imagine it's because the outer animation block doesn't have any animation – because the hide and show creates inner animation blocks – so it immediately calls the completion block.

Either remove the nested animation block in hide and show or add a parameter that disables animation for these nested animation actions.

Jason Harwig
  • 40,367
  • 5
  • 42
  • 44
  • I am not sure to totally understand what you are saying, but I redid my functions so all the animations won't be as nested as before. Still no luck. You can go back to my post to see the updated code – peterphonic Oct 04 '11 at 22:36