+
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions MapView/Map/RMMapView.m
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ - (void)dealloc
{
LogMethod();

[[NSNotificationCenter defaultCenter] removeObserver:self];

[self setDelegate:nil];
[self setBackgroundView:nil];
[self setQuadTree:nil];
Expand Down Expand Up @@ -2455,6 +2457,9 @@ - (void)setShowsUserLocation:(BOOL)newShowsUserLocation
_locationManager.headingFilter = 5;
_locationManager.delegate = self;
[_locationManager startUpdatingLocation];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];
}
else
{
Expand All @@ -2464,6 +2469,9 @@ - (void)setShowsUserLocation:(BOOL)newShowsUserLocation
[_locationManager release];
_locationManager = nil;

[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];

if (_delegateHasDidStopLocatingUser)
[_delegate mapViewDidStopLocatingUser:self];

Expand Down Expand Up @@ -2823,4 +2831,24 @@ - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *
}
}

#pragma mark -
#pragma mark system events

- (void)applicationDidEnterBackground:(UIApplication *)application {
if (_locationManager != nil) {
[_locationManager stopUpdatingLocation];
[_locationManager stopUpdatingHeading];
}
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
if (_locationManager != nil) {
if (_showsUserLocation == YES)
[_locationManager startUpdatingLocation];

if (_userTrackingMode == RMUserTrackingModeFollowWithHeading)
[_locationManager startUpdatingHeading];
}
}

@end
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载