I am making a view based application in which the first controller is viewcontroller there is login screen ,after login the next view is tabbar controller and I have 2 tabbar items on that tabbar .
Until this everything works fine . Now when i switch between these two views the viewWillDisappear
, viewDidUnload
is not called of previous tab clicked .
P.S.Even the viewwillAppear was not called ,which i called it with the Default Notification. Don't know what the issues are. Hope I am clear with my question.
First of all, when switching view in a UITabBarController, the viewDidUnload
function is not called because the view is not actually unloaded. So, this is normal.
What should work out of the box is viewWillAppear
/viewDidDisappear
. But there is a catch.
Depending on how you show your views, it might be that viewWillAppear
/viewDidDisappear
are not called by the framework for you. For example, this happens if you add your view as a subview, but there are more cases. I don't know how you display your tab bar, so cannot say anything more specific about it.
The easy solution I suggest to fix this is overriding the tabBarController:didSelectViewController:
selector in you tab bar controller delegate. From there you could implement you own logic or call viewDidDisappear
.
You should put your TabBar controller in MainWindow.xib.
First when you show loginscreen you will add your RootViewController like this:
[self.window addSubview:self.rootview.view];
And when login is complete you can remove your RootViewController from mainwindow and add TabBarController in the mainwindow like this:
[self.rootview.view removeFromSuperview];
[self.window addSubview:self.tabBarController.view];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With