I have a crash when trying to switch to another VC. Here is the structure:
TabBarController [Home, Tab2, Result tab]
from these tabs, I can push a new viewController called addVC which contains a UITextField
.
What I want to do, is to be able to follow this sequence: Tab2/Home (step1) => addVC (step2) => Result tab (step3)
To do this, I use this code in addVC :
[self.navigationController popToRootViewControllerAnimated:NO];
UITabBarController *tabbarController = ((UITabBarController*)appDelegate.window.rootViewController);
[tabbarController setSelectedIndex:2];
It works most of the time, but if the focus was in the textfield when I pop then push the result tab, the tab from the step1 is no longer accessible without a crash.
The crash log is:
[addVC respondsToSelector:]: message sent to deallocated instance 0x10977e60
NSZombie tells me that [UITextField canBecomeFirstResponder] has been called, causing the crash.
Since I use a storyboard, nothing except this is done programmatically. I guess my way to go to step3 is not the right one. I'm using ARC and I'm not releasing anything by myself.
Any ideas?
Thanks in advance.