applicationWillEnterForeground从未调用过

Ber*_*lor 3 iphone cocoa-touch objective-c

嘿那里,我在模拟器中尝试多任务(我只有第二代iPod和iPad),我仍然遇到一些问题.我的测试方法如下:

- (void)applicationDidBecomeActive:(UIApplication *)application {
 NSLog(@"Entering %s",__FUNCTION__);

 if (enteredFromBackground) {
  NSLog(@"Entering from Background");
  enteredFromBackground = NO;
 }
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
 NSLog(@"Entering %s",__FUNCTION__);

 enteredFromBackground = YES;
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,我没有从applicationWillEnterForeground看到NSLog,这就是为什么我在applicationDidBecomeActive中添加该行来向我展示一些东西.我得到的只是

2010-11-20 15:58:12.796 iBeat[45997:207] Entering -[AppDelegate_Shared applicationDidEnterBackground:]
2010-11-20 15:58:18.160 iBeat[45997:207] Entering -[AppDelegate_Shared applicationDidBecomeActive:]
Run Code Online (Sandbox Code Playgroud)

Lau*_*sac 7

在 iOS 13 中遇到这个问题后,我发现我正在等待applicationWillEnterForeground(_ application: UIApplication)被调用而不是sceneWillEnterForeground(_ scene: UIScene).

有关更多信息,请阅读此答案:

在此处输入链接描述


Ber*_*lor 5

最后我发现了我的问题!由于我有一个通用的应用程序,我有一个Appdelegate_Shared,一个Appdelegate_iPhone和一个Appdelegate_iPad.我在两个子类中有一个空的"applicationWillEnterForeground"实现,但没有调用super!

然后我想知道为什么Appdelegate_Shared中的方法永远不会被称为oO