iOS-App applicationWillEnterForeground und es blieb für eine Weile
Ich füge diese Funktion hinzu, um eine Benachrichtigung zu senden, wenn die App in den Vordergrund tritt:
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[[NSNotificationCenter defaultCenter] postNotificationName: @"UIApplicationWillEnterForegroundNotification" object: nil];
}
In meiner eigenen Klasse:
- (void) handleEnterForeground: (NSNotification*) sender
{
[self reloadTableData];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(handleEnterForeground:)
name: @"UIApplicationWillEnterForegroundNotification"
object: nil];
}
aber die handleEnterForeground: -Funktion wird zweimal aufgerufen, ich weiß nicht warum. Die reloadTableData: -Funktion ruft den Remote-Webservice auf. Wenn die App in den Vordergrund tritt, bleibt sie für eine Weile hängen.