0

I am working on an application that can push ViewControllers automatically by its own regarding some data I receive from websocket. The fact is when you press a button that also makes a push/pop viewController at the same time, it results in a corrupted navigation hierarchy and the app crashes :

nested push animation can result in corrupted navigation bar Unbalanced calls to begin/end appearance transitions for <**********ViewControlleriPhone: 0x16fb1990>.

So I am looking for a method in navigation controller (something like isPushingViewController ?) to know if I can make a push or not. I tried : IsBeingDismissed, IsBeingPresented with topViewController, or visibleViewController ... I cannot know if the navigation receive a push or not.

Could you help me fixing that please :) ?

user988168
  • 129
  • 2
  • 12
  • 1
    I don't think there's a property for that, however you could define your own using the UINavigationControllerDelegate and toggle a boolean using the willShowViewController and didShowViewController methods. Then when you need to do things you just inspect the boolean. Here's the docs: https://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationControllerDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UINavigationControllerDelegate/navigationController:didShowViewController:animated: – SeanCAtkinson May 24 '14 at 11:18
  • It seems that when you call pushViewController, the WillShowDelegate is called before pushing the second viewController. So, yes it could work. I'll code it, and make a bunch of tests to know if it works like this every time. Thanks dude! – user988168 May 24 '14 at 11:44
  • No problem. Once you've done the tests let me know if I should add it as the answer. – SeanCAtkinson May 24 '14 at 12:01

0 Answers0