Whenever MKMapView is initialised and set to a location
- (void) setMapLocationItem:(Location*)geofence{
if(self.mapView==nil){
self.mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
[self.mapView setDelegate:self];
[self.view addSubview:self.mapView];
[self.view sendSubviewToBack:self.mapView];
[self.view sendSubviewToBack:self.collectionView];
}
[self.mapView setHidden:NO];
[_mapView removeAnnotations:_mapView.annotations];
CLLocationCoordinate2D coordinate;
coordinate= CLLocationCoordinate2DMake(geofence.latitude.doubleValue, geofence.longitude.doubleValue);
CGFloat radius = 110;
if([geofence.radius boolValue])
radius = [geofence.radius floatValue];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance (coordinate, radius, radius);
[_mapView setRegion:region animated:NO];
self.annotation = [[MKPointAnnotation alloc] init];
self.annotation.coordinate = coordinate;
self.annotation.title = geofence.name;
self.annotation.subtitle = geofence.address;
[_mapView addAnnotation:self.annotation];
}
The memory used my the map is never released whenever the viewController is closed.
Its is only getting released when another MKMapView is initialized. Any thoughts as too why this is? I have referred the solutions in this question iOS6 MKMapView Memory Issue