5

I have a MKMapView (self.mapView) to which I add a MKCircle overlay (self.radiusOverlay) with a specific radius (self.location.radius).

Right below the MKMapView there is a UISlider (self.radiusSlider) which changes the overlay's radius on Value Changed:

- (void)viewWillAppear:(BOOL)animated {

    self.radiusOverlay = [MKCircle circleWithCenterCoordinate:CLLocationCoordinate2DMake([self.location.latitude floatValue], [self.location.longitude floatValue]) radius:[self.location.radius floatValue]];

    [self.mapView addOverlay:self.radiusOverlay];

    self.radiusSlider.value = [self.location.radius floatValue];
}

This is the method which does the radius-updating stuff:

- (IBAction)updateLocationRadius:(UISlider *)sender {

    [self.mapView removeOverlay:self.radiusOverlay];

    self.location.radius = [NSNumber numberWithFloat:sender.value];

    self.radiusOverlay = [MKCircle circleWithCenterCoordinate:CLLocationCoordinate2DMake([self.location.latitude floatValue], [self.location.longitude floatValue]) radius:[self.location.radius floatValue]];
    [self.mapView addOverlay:self.radiusOverlay];
}

This works fine, but it's not looking good: By removing and re-adding self.radiusOverlay I cause the overlay to flicker.

What can I do to avoid this flickering?

4

0 回答 0