iOS - detect when application exits

后端 未结 2 1156
予麋鹿
予麋鹿 2021-01-19 02:33

How can I detect when a user exits the application? (hitting the home button) And how can I detect when the relaunch it? (clicking the icon)

*I\'m not talking about

相关标签:
2条回答
  • 2021-01-19 03:05
    - (void)applicationDidEnterBackground:(UIApplication *)application
    

    and

    - (void)applicationDidBecomeActive:(UIApplication *)application
    

    In your AppDelegate.m

    - (void)applicationWillTerminate:(UIApplication *)application
    
    0 讨论(0)
  • 2021-01-19 03:05

    There's a notification UIApplicationDidGoToBackground that fires when the home button is pressed. A similar notification tells you about going back to foreground.

    0 讨论(0)
提交回复
热议问题