Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

My application has a navigation controller and I don't want any animation in it :

  • to prevent an animation when pushing a view, it's easy, via the pushViewController:animated: method

  • but when I click the "back" button on this subview, there's an animation ! KO ! What can I do to prevent this animation ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
629 views
Welcome To Ask or Share your Answers For Others

1 Answer

This prevents default animation.

- (void)viewWillDisappear:(BOOL)animated {
    [UIView setAnimationsEnabled: NO];
}

- (void)viewDidDisappear:(BOOL)animated {
    [UIView setAnimationsEnabled: YES];
}

In case if you need a custom animation

- (void)viewWillDisappear:(BOOL)animated {
    [UIView setAnimationsEnabled: NO];

    CATransition *transition = [CATransition animation];
    transition.duration = 0.3;
    transition.type = kCATransitionFade;
    [self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
}

- (void)viewDidDisappear:(BOOL)animated {
    [UIView setAnimationsEnabled: YES];
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...