Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i wait until an animation in a different class is finished before continuing?

I have the simple code of:

[otherClass doMethodOneWhichHasAnimation];

and that animation lasts 0.8 seconds. Followed by code that pushes a viewcontroller:

SchemeView *schemeView = [[SchemeView alloc] init];
    [self.navigationController pushViewController:schemeView animated:YES];
    [schemeView release];

The problem is, it pushes the viewcontroller without waiting, and I'd like it to wait. Doing delay just delays the whole thing, including the first animation from starting.

How can i get it to wait the 0.8 seconds before running the second bit of code?

like image 541
Andrew Avatar asked Jun 13 '11 11:06

Andrew


1 Answers

You can push after the animation is done

[UIView animateWithDuration:0.8
        animations:^{ 
            // Animation
        } 
        completion:^(BOOL finished){

          // PushView

        }];

for < iOS 4+ take a look at setAnimationDidStopSelector

or

[self performSelector:@selector(metohodToPushView) withObject:nil afterDelay:0.8];
like image 190
FoJjen Avatar answered Nov 03 '22 22:11

FoJjen