- (void)viewWillAppear:(BOOL)animated detect custom animation

1.7k views Asked by At

I have a button which when pressed pushes a view controller however i'm using a custom animation so pushViewController: childController animated: is set to NO. What i want to do though is detect this custom animation in my - (void)viewWillAppear:(BOOL)animatedmethod and write an if statement like this;

- (void)viewWillAppear:(BOOL)animated { 
     if (customAnimation occured) {//Do this} 
     else {//Do this}
}

This is the method for my button which pushes the view controller.

- (void)nextPressed:(id)sender {
    childController = [[CategoryOneDetailController alloc] initWithNibName:xibDownName bundle:nil];
    [UIView  beginAnimations: @"Showinfo"context: nil];
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.75];
    [self.navigationController pushViewController: childController animated:NO];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO];
    [UIView commitAnimations];
    [childController release];
}

Any help would be much appreciated, thanks, Sami.

1

There are 1 answers

7
Eiko On BEST ANSWER

If you don't use standard animations, I think your best bet is to add a property to your pushed view controller that is set to YES in case of a custom animation (and NO by default to not break any existing behavior). Then you can check that property in viewDidAppear:.

If you need your custom logic to be executed after the animation has run, you might want to set up an animation completion handler or block.