Reputation: 313
for all of my view controller.m I have the majority of my code in:
- (void)viewDidAppear:(BOOL)animated
So, each time I switch between tab bars all of the info in each view refreshes. (which is good!) Although, when I open the app from the home screen the tab won't update...I have to switch to another tab and back again to get it to load.
Any solutions?
Upvotes: 0
Views: 5369
Reputation: 14154
You need to sign up for a notifications to handle it. Register each tab for the notification and a method to handle it. Then just perform your viewDidAppear. It works like a charm.
-(void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(becomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
}
-(void)becomeActive:(NSNotification *)notification {
// only respond if the selected tab is our current tab
if (self.tabBarController.selectedIndex == 0) { // Tab 1 is 0 index, Tab 2 is 1, etc
[self viewDidAppear:YES];
}
}
Upvotes: 3
Reputation: 839
Maybe you can invoke all your refreshing code in
(void)applicationDidBecomeActive:(UIApplication *)application
{
}
this method is in your AppDelegate.
Upvotes: 0
Reputation: 171
Try putting this in the view controller's m file:
- (IBAction)done:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
Upvotes: -1