我只有在运行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的开发者论坛上得到更好的回应。 –