开发者

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

开发者 https://www.devze.com 2023-03-15 07:20 出处:网络
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

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 = [[CategoryOneDetailControll开发者_运维百科er 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.


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.

0

精彩评论

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