iOS 中的不同背景模式



要识别我的应用程序进入后台模式[单击一个简短的主页按钮] 我使用此功能:

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

但是,如何识别我的应用程序进入应用程序切换模式[两次短暂的主页按钮点击]?在这种情况下,不调用方法 applicationDidEnterBackground

试试这个:

    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.
    }

相关内容

  • 没有找到相关文章

最新更新