iOS中的不同背景模式

时间:2018-12-20 07:33:19

标签: ios swift ios-background-mode

要识别我进入了背景模式的应用,请执行以下操作:

func applicationDidEnterBackground(_ application: UIApplication) {
    //...
}

但是如何识别我的应用已进入应用切换模式 [两次按下主屏幕按钮]?在这种情况下,不会调用方法applicationDidEnterBackground

1 个答案:

答案 0 :(得分:1)

尝试一下:

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }