5

特定の半径 (self.location.radius) を持つ MKCircle オーバーレイ (self.radiusOverlay)を追加するMKMapView (self.mapView) があります。

MKMapViewのすぐ下に、Value Changedでオーバーレイの半径を変更するUISlider (self.radiusSlider) があります。

- (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];
}

これは、半径の更新を行うメソッドです。

- (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];
}

これは問題なく動作しますが、見栄えがよくありません。self.radiusOverlayを削除して再度追加すると、オーバーレイがちらつきます。

このちらつきを避けるにはどうすればよいですか?

4

0 に答える 0