I have three tabs. When I press the tab button on the bottom, is it possible show the original view of the tab. Because when I change the view of tab1, go to tab2, then go back to tab1, I do not get the original tab1 view. The changes in tab1 remain. Is it possible to to reset tab1 view when I go back to it?
+1
A:
UITabBarController has a delegate property, which means you can assign another object that conforms to the UITabBarDelegate protocol. If you want something to happen when the user switches tabs, then the delegate object only needs to implement this method:
-[id<UITabBarDelegate> tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item];
In that method you can do all the view swapping or whatever that you want.
Dave DeLong
2009-07-04 19:17:23
+1
A:
If you're on tab1 and switch to tab2, the view of tab1 isn't unloaded. So if you switch back from tab2 to tab1, you're exactly at the same state as before. Usually that's how it is intended to be. However, you can do stuff (like resetting the view) by implementing the viewDidAppear
method in tab1's view controller.
- (void)viewDidAppear:(BOOL)animated
Andreas
2009-07-06 09:14:25