我只有在運行iOS 9.0或更高版本的實際設備上纔有完全相同的問題。
我結束了我定義自己的通知:
(這個定義應該是全局可用,constants.h
或類似)
#define myAppBecameActiveNotif @"Tito, your app is active"
然後,在你的AppDelegate實現(AppDelegate.m大多數情況下),你實現applicationDidBecomeActive
委託方法:
- (void)applicationDidBecomeActive:(UIApplication *)application {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:myAppBecameActiveNotif
object:nil];
});
}
(只是耽誤您的通知派遣了一下,讓你的組件來生活)
現在,在類,你希望得到通知的應用變得活躍起來你做
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(whatToDoWhenAppActive:)
name:myAppBecameActiveNotif
object:nil];
現在的工作很好。你會看到你無法感受到這個500毫秒的延遲...
由於iOS 9處於測試階段,你可能會在Apple的開發者論壇上得到更好的迴應。 –