开发者

Check if viewController push was animated or not

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: UIViewAnimationCurveEaseInO开发者_如何转开发ut];
    [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.


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?
    }
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜