ViewDidUnload, viewWillDisappear not called in tabBarContoller

I am making an application based on a view in which the first controller is the view manager, there is a login screen, after logging in the next view is the panel controller and I have 2 tabs on this tab. So far, this is all working fine. Now, when I switch between these two views, viewWillDisappear , viewDidUnload not called by the previous tab.

PS Even if viewwillAppear was not called, I called it with a default notification. I don’t know what the problems are. Hope I understood my question.

+4
source share
3 answers

First of all, when switching a view to a UITabBarController, the viewDidUnload function viewDidUnload not called because the view is not actually unloaded. So this is normal.

What should work out of the box viewWillAppear / viewDidDisappear . But there is a catch. Depending on how you display your views, it may be that viewWillAppear / viewDidDisappear not called by the framework for you. For example, this happens if you add your view as a subtitle, but there are more cases. I don’t know how you display the tab bar, so you cannot say anything more specific about this.

A simple solution, I propose to fix this, is overriding the tabBarController:didSelectViewController: selector in your tab bar controller delegate. From there, you can implement your own logic or call viewDidDisappear .

+6
source

You must put your TabBar controller in MainWindow.xib.

First, when you show loginscreen, you add a RootViewController as follows:

 [self.window addSubview:self.rootview.view]; 

And when the login is complete, you can remove the RootViewController from mainwindow and add the TabBarController to mainwindow as follows:

  [self.rootview.view removeFromSuperview]; [self.window addSubview:self.tabBarController.view]; 
+1
source

Do you have a UINavigationController? You do not refer to it. If you are not using the UINavigationController, most likely your UITabBarController will not be configured correctly as topViewController.

0
source

All Articles