Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
Add logic to handle view appearance.
Browse files Browse the repository at this point in the history
  • Loading branch information
yo1995 committed Aug 23, 2021
1 parent 7579ed2 commit d68ad66
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ class SetUpLocationDrivenGeotriggersViewController: UIViewController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Restart the simulated location updates.
if simulatedLocationDataSource != nil {
mapView.locationDisplay.start()
}
geotriggerMonitors.forEach { monitor in
if monitor.status == .stopped {
monitor.start()
Expand All @@ -254,9 +258,13 @@ class SetUpLocationDrivenGeotriggersViewController: UIViewController {

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
// Stop location updates when the view disappears.
mapView.locationDisplay.stop()
geotriggerMonitors.forEach { $0.stop() }
observers.forEach(NotificationCenter.default.removeObserver)
observers.removeAll()
observers.removeAll(keepingCapacity: true)
// Clear all received "entered" notifications.
featureNamesInFenceGeotrigger.removeAll(keepingCapacity: true)
}
}

Expand Down

0 comments on commit d68ad66

Please sign in to comment.