我有MKMapView
一个视图控制器,我在其中调用:
[self.mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
当我导航到另一个视图控制器并且带有地图视图的视图控制器消失时,我仍然在运行位置服务(我看到状态栏中的箭头)。一旦我不再看到地图,我想将其关闭,但我不知道如何在没有CLLocationManager
...的情况下执行此操作
谢谢
我有MKMapView
一个视图控制器,我在其中调用:
[self.mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
当我导航到另一个视图控制器并且带有地图视图的视图控制器消失时,我仍然在运行位置服务(我看到状态栏中的箭头)。一旦我不再看到地图,我想将其关闭,但我不知道如何在没有CLLocationManager
...的情况下执行此操作
谢谢
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if ([CLLocationManager significantLocationChangeMonitoringAvailable])
{
if (OUTPUT_LOGS) NSLog(@"Stopped monitoring for significant changes");
[[self locationManager] stopMonitoringSignificantLocationChanges];
}
[[self locationManager] startUpdatingLocation];
}
-(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
if ([CLLocationManager significantLocationChangeMonitoringAvailable])
{
[self.locationManager startMonitoringSignificantLocationChanges];
}
[[self locationManager] stopUpdatingLocation];
}
这似乎有效:
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
self.mapView.showsUserLocation = NO;
[self.mapView setUserTrackingMode:MKUserTrackingModeNone animated:YES];
}