iOS app crashing when selecting at UITabItem

982 views Asked by At

I seem to have a very strange problem. My app has a UITabBar which lets you select various view controllers. If in a given selected tab item, another view controller is pushed onto the stack and then popped off the UINavigationController's stack using either storyboard segues or pushViewController or popViewController, when you select another tab item, the app crashes. I traced this and discovered that have a zombie object, namely the viewcontroller that was pushed and then popped. The app is apparently trying to send a message to it. Here is the log message.

*** -[UserInputViewController respondsToSelector:]: message sent to deallocated instance 0xa5f0620

I see nowhere in my code where I am accessing the viewcontroller once it's been popped off the stack and presumably deallocated, and I don't do any special processing when the tab bar item is clicked. In fact it crashes before

 - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController

is even called. It would appear that somehow the tab bar still thinks this viewcontroller is allocated and on the stack, otherwise why would it try to send it a message?

Any help is greatly appreciated.

1

There are 1 answers

0
Peter Jacobs On

Found this problem. That deallocated view controller was actually being assigned to be the UITabBarController's delegate! Oops. Found this answer here.

View Controller getting a message sent to it after release, causes a crash