She*_*lam 4 iphone cocoa-touch objective-c uitableview multitasking
reloadData
在用户退出应用程序后,我希望我的UITableView能够再次激活我的应用程序.我知道我需要实现(在我的app委托中):
- (void)applicationDidBecomeActive:(UIApplication *)application
但我不知道如何引用当前的UITableView?
更新:我的UITableView是一个单独的控制器.它实际上呈现如下
AppDelegate > Root View Controller > Pushes UITabBarController modally which has a UITableViewController
Run Code Online (Sandbox Code Playgroud)
Aar*_*ers 30
跟进Ole的上述答案
在初始化viewcontroller时添加它
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(becomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
Run Code Online (Sandbox Code Playgroud)
在控制器中添加实际方法
- (void)becomeActive:(NSNotification *)notification {
NSLog(@"becoming active");
}
Run Code Online (Sandbox Code Playgroud)
一定要清理通知
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
Run Code Online (Sandbox Code Playgroud)