How to refresh UITableView after app comes becomes active again?

僤鯓⒐⒋嵵緔 提交于 2019-11-29 02:37:36
Aaron Saunders

following up on Ole's answer above

add this when initializing the viewcontroller

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

add the actual method in the controller

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

be sure to clean up the notification

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

If you can't access your view controller from the app delegate, you could also have your controller listen to the UIApplicationDidBecomeActiveNotification notification.

you can create your class called TableViewManager. in there register list of UITableView so that you can refresh any table you want. it's like this, in yourTableViewManager class, you have a method called

- (void)RefreshTableView:(UITableView *)tableView {
if(tableView != nil)
    [tableView reloadData]; }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!