From d68ad66b716874f462f8941e0697a43446f09025 Mon Sep 17 00:00:00 2001 From: Ting Chen Date: Mon, 23 Aug 2021 16:32:25 -0700 Subject: [PATCH] Add logic to handle view appearance. --- .../SetUpLocationDrivenGeotriggersViewController.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arcgis-ios-sdk-samples/Display information/Set up location-driven Geotriggers/SetUpLocationDrivenGeotriggersViewController.swift b/arcgis-ios-sdk-samples/Display information/Set up location-driven Geotriggers/SetUpLocationDrivenGeotriggersViewController.swift index d8276e2cb..f52efba12 100644 --- a/arcgis-ios-sdk-samples/Display information/Set up location-driven Geotriggers/SetUpLocationDrivenGeotriggersViewController.swift +++ b/arcgis-ios-sdk-samples/Display information/Set up location-driven Geotriggers/SetUpLocationDrivenGeotriggersViewController.swift @@ -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() @@ -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) } }