【发布时间】:2020-10-16 06:39:19
【问题描述】:
我的一个应用程序有问题。我注意到,当应用程序在后台时,我的控制器仍在更新。原因是 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,清理构建文件夹。
- 清理开发者文件夹
- 请勿使用扩展程序。
- 调试或发布方案
没有任何效果,方法仍然没有被调用,我想知道为什么?
【问题讨论】:
标签: ios swift xcode uiviewcontroller uiscenedelegate