I’m assuming my app is sent notifications through NSNotificationCenter
when these kind of events happen. Does anyone know what these are?
相关问题
- Can NSNotificationCenter be used between different
- Notification Center vs. Delegation in iOS SDK
- ios notifications to “dead” objects
- How to detect switch between macOS default & dark
- Swift NotificationCenter remove observer quickest
相关文章
- Swift NotificationCenter remove observer quickest
- AVPlayer not finishing when streaming via AirPlay
- Why does EAAccessoryDidConnectNotification occur t
- KVO versus NSNotifications [duplicate]
- How to check internet connectivity in ios?
- NSManagedObject's hasChanges is true while cha
- Is NSNotificationCenter thread safe?
- Xamarin NSNotificatioCenter: How can I get the NSO
In the app I'm working on I needed to handle these events as well and did so using the following two notifications:
UIApplicationWillResignActiveNotification >> This notification is fired when the Notification Center or Control Center is brought up.
UIApplicationWillEnterForegroundNotification >> This notification is fired when the Notification Center or Control Center is dismissed.
These events can naturally be handled from the AppDelegate:
Though depending on your app it will likely be easier to explicitly listen for these events in the View Controller(s) that needed to be aware of this:
... and implement your selectors:
And lastly remove yourself as an observer when you're done: