I need to detect when my app becomes visible? (for example by double tapping the Home button and then tapping on an app that is already in the background) If possible, I would like to detect that event inside my UIViewController. I am working with Swift 2.2.
Asked
Active
Viewed 1.2k times
7
-
Are you trying to detect when your app comes to the foreground or some other app? – Abizern Aug 19 '16 at 15:56
-
1Thanks for pointing that out, no need to downvote. @CodeBender – Josh Aug 19 '16 at 16:11
1 Answers
19
You can use the applicationDidBecomeActive(_:)
method of your UIApplicationDelegate
. You should read up on the app lifecycle. Your app delegate would then need to inform your view controller in some fashion.
Or you can register your view controller as an observer of the UIApplicationDidBecomeActive
notification. Documentation for that can be found here

keithbhunter
- 12,258
- 4
- 33
- 58