如何刷新UITableView后应用程序变得活跃? [英] How to refresh UITableView after app comes becomes active again?
问题描述
在用户退出应用程序后,如果我的应用程序再次处于活动状态,我希望我的UITableView reloadData
。我知道我需要实现(在我的应用程序委托):
- (void)applicationDidBecomeActive:(UIApplication *)application
但不知道如何引用当前的UITableView?
更新:
UITableView是一个单独的控制器。它实际上如下所示:
AppDelegate>根视图控制器>以Ole的形式按下具有UITableViewController的UITabBarController
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(becomeActive :)
name:UIApplicationDidBecomeActiveNotification
object:nil];
在控制器中添加实际方法
- (void)becomeActive:(NSNotification *)notification {
NSLog(@become active);
}
请务必清除通知
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc]
}
I would like my UITableView to reloadData
once my app is active again, after a user exits the application. I know I need to implement (in my app delegate):
- (void)applicationDidBecomeActive:(UIApplication *)application
but im not sure how to reference the current UITableView?
UPDATE: My UITableView is a separate controller. It is actually presented as follows
AppDelegate > Root View Controller > Pushes UITabBarController modally which has a UITableViewController
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];
}
这篇关于如何刷新UITableView后应用程序变得活跃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!