Я добавляю эту функцию, чтобы публиковать уведомление, когда приложение выходит на передний план:
- (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: функция вызовет удаленный веб-сервис, поэтому, когда приложение войдет переднем плане, он застрянет на некоторое время.