How to update UITableView after application is activated again?

I want my UITableView to be reloadData when my application activates again after the user exits the application. I know what I need to implement (in my application):

- (void)applicationDidBecomeActive:(UIApplication *)application

but not sure how to reference the current UITableView?

UPDATE: My UITableView is a separate controller. It is presented as follows

 AppDelegate > Root View Controller > Pushes UITabBarController modally which has a UITableViewController 
+4
source share
3 answers

after ole answer above

add this when initializing the view manager

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(becomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil]; 

add the actual method to the controller

 - (void)becomeActive:(NSNotification *)notification { NSLog(@"becoming active"); } 

be sure to clear the notice

 - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; [super dealloc]; } 
+30
source

If you cannot access the view controller from the application delegate, you can also listen to your controller with the UIApplicationDidBecomeActiveNotification notification.

+3
source

You can create your own class called TableViewManager . there, register a UITableView list to refresh any table you want. this is so, in your TableViewManager class you have a method called

 - (void)RefreshTableView:(UITableView *)tableView { if(tableView != nil) [tableView reloadData]; } 
0
source

Source: https://habr.com/ru/post/1316434/


All Articles