我希望一旦我的应用程序再次激活,在用户退出应用程序后,我希望我的UITableView可以reloadData。我知道我需要实现(在我的应用程序委托中):
- (void)applicationDidBecomeActive:(UIApplication *)application
但是我不确定如何引用当前的UITableView?
更新:我的UITableView是一个独立的控制器。它实际上是这样呈现的
AppDelegate > Root View Controller > Pushes UITabBarController modally which has a UITableViewController发布于 2010-07-21 23:58:32
跟进上面Ole的答案
在初始化视图控制器时添加这个
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(becomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];在控制器中添加实际的方法
- (void)becomeActive:(NSNotification *)notification {
NSLog(@"becoming active");
}请务必清理通知
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}发布于 2010-07-21 23:31:35
如果你不能从应用代理访问你的视图控制器,你也可以让你的控制器监听UIApplicationDidBecomeActiveNotification通知。
发布于 2010-07-21 23:41:19
您可以创建名为TableViewManager的类。在这里注册UITableView列表,以便您可以刷新任何您想要的表。就像这样,在您的TableViewManager类中,有一个名为
- (void)RefreshTableView:(UITableView *)tableView {
if(tableView != nil)
[tableView reloadData]; }https://stackoverflow.com/questions/3300694
复制相似问题