我的一个应用程序有问题。我注意到,当应用程序在后台运行时,我的控制器仍在更新。原因是 AppDelegate 的方法没有被调用,我不知道为什么。
这是我的代码:
import UIKit
import Harmony
@UIApplicationMain
class AppDelegate : UIResponder
{
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
return true
}
}
extension AppDelegate : UIApplicationDelegate
{
func applicationDidBecomeActive(_ application: UIApplication)
{
Swift.print("applicationDidBecomeActive")
Notifications.post(UIApplication.didBecomeActiveNotification.rawValue)
}
func applicationWillResignActive(_ application: UIApplication)
{
Swift.print("applicationWillResignActive")
Notifications.post(UIApplication.willResignActiveNotification.rawValue)
}
func applicationWillEnterForeground(_ application: UIApplication)
{
Swift.print("applicationWillEnterForeground")
Notifications.post(UIApplication.willEnterForegroundNotification.rawValue)
}
}
我尝试了以下方法:
- 使用真实设备和模拟器。
- 重新启动 Xcode,清理构建文件夹。
- 清理开发人员文件夹
- 不要使用扩展名。
- 调试或发布方案
没有任何效果,这些方法仍然没有被调用,我想知道为什么?