8

My app has one big problem. Mainly on iOS 8 because we have not found this on other iOS versions.

It will freeze sometimes when push to a new view controller or pop to a previous view controller. But something strange is if you press home button and launch the app from background. It will run a little. Here I mean the new pushed or popped view controller appeared but you still could not push or pop new view controllers.


update: The memory, CPU and disk usage are all normal when the app freeze.

sunkehappy
  • 8,970
  • 5
  • 44
  • 65
  • Do you have any code to share around when it does push/pop and the code that you have in the likes of `viewDidLoad` I've found in the past that it is sometimes in `viewDidLoad` but it looks as though it is in the one doing the push/pop? Also do you have a crash report? Or console output? – Popeye Oct 31 '14 at 12:04
  • @Popeye Sorry the app could freeze at any page. So no very relative code to share. – sunkehappy Oct 31 '14 at 12:07
  • We need something to narrow it down, just saying it could crash mon any page just makes it even harder for us to give an answer without code. – Popeye Oct 31 '14 at 12:09
  • @Popeye I know what you want to say but I really could not find any tips to handle this bug. This is too strange. If I could I will definitely solve it myself instead of post a question without so much information here. Sorry. – sunkehappy Oct 31 '14 at 12:13
  • Sorry but I don't think we could really help you, if you're the one with the code and you can't solve it I'm not sure it will be possible for us to help you with it. Sorry dude – Popeye Oct 31 '14 at 12:14
  • just a wild guess, are you doing the push/pop on a background thread? – MDB983 Oct 31 '14 at 14:12

1 Answers1

25

We have solved this problem finally. The reason is we have not disabled the interactivePopGestureRecognizer when the view controller stack have only 1 view controller. Add the check will solve the problem. See code bellow.

- (void)navigationController:(UINavigationController *)navigationController
       didShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animate
{
    if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])
    {
        if (self.viewControllers.count > 1)
        {
            self.interactivePopGestureRecognizer.enabled = YES;
        }
        else
        {
            self.interactivePopGestureRecognizer.enabled = NO;
        }
    }
}
sunkehappy
  • 8,970
  • 5
  • 44
  • 65
  • Thank you for your answer. You save my job. :) – Alvin John Sep 26 '16 at 11:21
  • Could someone can explain why interactivePopGestureRecognizer will freeze navigation controller push new view controller (I did receive new view controller's func viewWillAppear, but not receive viewDidAppear.). – Wei Aug 18 '21 at 09:23