0

In my viewDidLoad method i would like to check how the viewController was pushed was it animated or not.

As in some cases it is animated and in others it is not and depending on wether it was animated or not i would like to display some controls.

This is how i'm pushing my viewController.

childController = [[CategoryOneDetailController alloc] initWithNibName:xibDownName bundle:nil];
[self.navigationController pushViewController:childController animated:NO];

Can anyone help me?

Thanks, Sami.

Edit

The - (void)viewWillAppear:(BOOL)animated method worked well I tested it with some log messages, however once the view has been loaded if on my view i have a button which when clicked calls this method

- (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];

}

Now when this second view is pushed the log reports it is not animated, but it is and this is where i need to check wether the push was animated or not.

Sami
  • 1,374
  • 1
  • 16
  • 43

2 Answers2

1

implement viewDidAppear:(BOOL)animated or viewWillAppear:(BOOL)animated

In your ViewController:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    if(animated) {
        //do what ever is needed when animted
    } else {
        //what will you do, if not animated?
    }
}
vikingosegundo
  • 52,040
  • 14
  • 137
  • 178
  • How would i do this, apologise i'm quite new to Objecctive-C. – Sami Jun 22 '11 at 21:41
  • Thanks, i tried your method however i'm still having problems, please see my edit. – Sami Jun 22 '11 at 22:17
  • can u post your `viewWillAppear:` too? – vikingosegundo Jun 22 '11 at 22:44
  • Sorry i see why it's not working, it's because i'm using a custom animation when the button is pressed and pushViewController: childController animated: is set to NO, i've rewritten the question please take a look http://stackoverflow.com/questions/6450869/voidviewwillappearboolanimated-detect-custom-animation – Sami Jun 23 '11 at 07:45
0

The only time the viewController is pushed without being animated is if the app is launched. Any other pushes will by default be animated unless you explicitly specify NO for animated parameter.

Ahmad
  • 12,336
  • 6
  • 48
  • 88