【发布时间】:2012-05-25 18:39:47
【问题描述】:
我添加了这个功能,当应用进入前台时发布通知:
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[[NSNotificationCenter defaultCenter] postNotificationName: @"UIApplicationWillEnterForegroundNotification" object: nil];
}
在我自己的班级里:
- (void) handleEnterForeground: (NSNotification*) sender
{
[self reloadTableData];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(handleEnterForeground:)
name: @"UIApplicationWillEnterForegroundNotification"
object: nil];
}
但是handleEnterForeground: 函数会调用两次,我不知道为什么。这 reloadTableData: 函数会调用远程 webService ,所以当应用进入 前台,它会卡住一段时间。
【问题讨论】:
标签: ios uiapplicationdelegate background-foreground