Custom view controller transitions are fast becoming my favourite iOS 7 API addition. As with all new things, there are surprises and side effects to learn about. This post is about one such issue, in this triangle:
There are 3 view controllers. First one (list) can either directly go to the 3rd (details), or it can first open the search controller in the middle, from where you can go to details as well. It’s all done through
Custom transitions exist only between 1st and 3rd VC and vice versa. Thus, both of this VCs are
UINavigationControllerDelegate’s, as indicated by yellow circles and they contain this code:
1 2 3 4 5 6 7 8 9 10 11 12
Search controller has no custom transition.
These are the steps:
- on 1st (List) VC, tap to open Search VC
- on Seach VC, tap to open Details VC
- Go back to Search
- now, either try open another instance of Details VC or go back to List VC
App will crash on step 4.
Adding an Exception Breakpoint on throw, I got this stack trace:
Notice the second line from the top, just below objc_msgSend. Apparently it tries to get an instance of custom transition and crashes.
Rather simple - in Search VC, clear the UINC delegate.
1 2 3 4 5