Restore pre-iOS7 UINavigationController pushViewController animation

前端 未结 10 2337
终归单人心
终归单人心 2020-11-30 21:14

So. Just started transitioning my IOS code to IOS7, and ran into a bit of problem.

I\'ve got a UINavigationController, which has child ViewControllers a

10条回答
  •  爱一瞬间的悲伤
    2020-11-30 22:08

    I voted for @Arne's answer, because I find it the most elegant solution to this problem. I would just like to add some code in order to answer to @Bill's problem from his comment on @Arne's solution. Here's comment quote:

    Thanks, this works for me. However, when the user taps the Back button, it reverts to the busted animation (because the back button doesn't call popViewControllerRetro). – Bill Oct 3 at 12:36

    In order to call popViewControllerRetro when back button is pressed, there's a small hack you can perform in order to achieve this. Go into your pushed view controller, import UIViewController+Retro.h and add this code in your viewWillDisappear method:

    - (void)viewWillDisappear:(BOOL)animated {
        if ([self.navigationController.viewControllers indexOfObject:self] == NSNotFound) {
            [self.navigationController popViewControllerRetro];
        }
    
        [super viewWillDisappear:animated];
    }
    

    This if statement will detect when Back button is pressed and will call popViewControllerRetro from category class.

    Best regards.

提交回复
热议问题