我希望我的 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/