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

笑着哭i 提交于 2019-12-11 03:32:05

问题


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:


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.



来源:https://stackoverflow.com/questions/6450869/voidviewwillappearboolanimated-detect-custom-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!