I am designing an app which enables users to login, give a list of Categories, SubCategories and SubSubCategories and then show the products inside of those chosen categories.
To do this I have a UITabBarController with 5 tabs, all of which are UINavigationControllers with the root of each page respectively. The first of the tabs (called products) has the navigation structure I have described above, Categories -> SubCategories- SubSubCategories -> Products
Now to the problem.... When navigating through this the first time around this will work completely fine, I am able to browse and select categories and products. However if I am to go all the way to the products and press back to the Categories and start again for a second time, if I select a subCategory the navigationController will return a null reference exception.
I am pushing the view controllers using navigationController.PushViewController(viewController, true) and am not doing any modal presentation as seen in existing questions.
I do hope someone can help. Thanks, James McNulty
CodePudding user response:
So I am answering my own question..... For those that may encounter this issue and maybe even a note to self.
So in the Events that I had created I had forgot to unattached the event from the action in my viewDidDissapear() Method - You should state....
Tapdelegate.Selected -= EventMethod
This is because not doing this or doing this before the method is invoked will cause the viewcontroller to stay in memory and therefore when using
NavigationController.PushViewController(viewcontroller, bool)
will use the same handle that was used for the initial invocation of the event. This is a no.no. BIG SAD !!!!
Hope this helped you out if you too are having this problem. Enjoy.