0
在我的應用程序中我想添加覆蓋圖來映射,當用戶拖動滑塊時,覆蓋圖 circle radius必須改變,但有時會拋出線程異常。 我的代碼:MKMapView addOverlays線程錯誤
- (void)addCircleWithRadius:(NSNumber *)radius
{
MKCircle *circle = [MKCircle circleWithCenterCoordinate:userlocation radius:[radius doubleValue] ];
[circle setTitle:@"background"];
MKCircle *circleLine = [MKCircle circleWithCenterCoordinate:userlocation radius:[radius doubleValue]];
[circleLine setTitle:@"line"];
NSArray *overlays = [NSArray arrayWithObjects:circle,circleLine, nil];
[mapView addOverlays:overlays];
}
-(void)slider_change:(id)sender
{
@try {
[mapView removeOverlays:[mapView overlays]];
if([mapView.overlays count] == 0)
{
CLLocationCoordinate2D _coordinate ;
_coordinate.latitude = 35.692995;
_coordinate.longitude = 51.421509;
NSNumber *value = [NSNumber numberWithFloat:slider.value * 1000];
[self addCircleWithRadius:value];
}
}
@catch (id exception) {
}
}