2
votes

I have two different UIViewControllers on the same UINavigationController. Both contain a tableview. If one of the cells on the first view controller is tapped, the second controller is pushed. If one of the cells in the second is pushed, another instance of the second controller is pushed.

When using the back button to go back, this all works perfectly. However, when using iOS 7's interactivePopGestureRecognizer, moving from one instance of the second view to another causes a crash.

I have statements logging the navigation controller activity and the gesture recognizer start.

This is the output when starting and then canceling the pop gesture:

Push <ViewController2: 0x15597f60>
Will show <ViewController2: 0x15597f60>
Did show <ViewController2: 0x15597f60>

Push <ViewController2: 0x15638b80>
Will show <ViewController2: 0x15638b80>
Did show <ViewController2: 0x15638b80>

Interactive pop started
Will show <ViewController2: 0x15597f60>

-navigationController:didShowViewController:animated: is never called. After this, attempting the gesture again will take you back to the first view controller (i.e. one pop too many), but the navigation bar will still display a back button and the title of the second view.

And then this is the output when attempting to pop normally:

Push <ViewController2: 0x15597f60>
Will show <ViewController2: 0x15597f60>
Did show <ViewController2: 0x15597f60>

Push <ViewController2: 0x15638b80>
Will show <ViewController2: 0x15638b80>
Did show <ViewController2: 0x15638b80>

Interactive pop started
Will show <ViewController2: 0x15597f60>
Unbalanced calls to begin/end appearance transitions for <ViewController1: 0x156e7050>.
Did show <ViewController1: 0x156e7050>

Any ideas as to why this is occurring?

1
how come the second run (pop normally) will display "interactive pop started"? is this just the normal action handler that prints the log? or are you doing something different?sergio
What are you trying to accomplish? Do you want to tie the recogniser to another recogniser? It should just work as expected without any code. If you are pushing the view controllers correctly onto the navigation stack there should not be any problems.Mundi
@sergio I have NSLog statements in the gesture recognizer's delegate to print "Interactive pop started"jaggedcow
@Mundi I'm just trying to use it normally, nothing special. The only reason I touched the recognizer at all was because it wasn't working properly.jaggedcow

1 Answers

2
votes

The problem is that the navbar is hidden. If you enable the navbar, the problem goes away. It's definitely a bug in Apple's implementation. Found the answer right when I put a bounty on it. Yikes.

See this for more information and a possible fix: https://stackoverflow.com/a/19834167/505259

UPDATE: Dennis' workaround did not work for me. One workaround I'm working on now is to NEVER TOUCH the interactivePopGestureRecognizer's delegate. Leave it alone. I suggest keeping the navigationBar alive but hidden (without using the hidden property, perhaps by hiding the subviews manually or by reordering the navigation bar layer to the back).

SECOND UPDATE: You can keep a reference to the current interactivePopGestureRecognizer's delegate (which is some private object you shouldn't touch). Then when you set the delegate to your own custom implementation, pass the delegate method calls back to the original private object. That should fix the problem entirely.