iphone - 应用程序再次激活后如何刷新 UITableView?

标签 iphone objective-c cocoa-touch uitableview multitasking

我希望我的 UITableView 在用户退出应用程序后再次激活时 reloadData。我知道我需要实现(在我的应用委托(delegate)中):

- (void)applicationDidBecomeActive:(UIApplication *)application

但我不确定如何引用当前的 UITableView?

更新: 我的 UITableView 是一个单独的 Controller 。实际呈现如下

AppDelegate > Root View Controller > Pushes UITabBarController modally which has a UITableViewController

最佳答案

跟进 Ole 上面的回答

在初始化viewcontroller时添加这个

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

在 Controller 中添加实际的方法

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

一定要清理通知

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

关于iphone - 应用程序再次激活后如何刷新 UITableView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3300694/

相关文章:

iphone - 使用 NSFetchedResultsController 排序时如何忽略前缀 "A"和 "The"?

iOS UINavigationController barHideOnTapGestureRecognizer 和 UIButton 干扰

iphone - 制作一个跨 View Controller 重复的函数 DRY

ios - 分派(dispatch)到并发队列导致在主线程上执行?

ios - 在没有全屏的情况下将一个 View Controller 呈现在另一个 View Controller 之上

iphone - MPMoviePlayerController 播放 YouTube 视频

ios - 应用仅在装有iOS 7.1的iPhone 4中挂起

objective-c - 你如何抚摸 NSAttributedString 的_outside_?

ios - 强制 Objective-C 对象使用某个委托(delegate)

ios - 在 Mapbox iOS SDK 上动态更改 MGLPointAnnotation 图像