0

The firs two-three rimes I tested the app and it crashed a few times after I used the UISlider created to change a circle´s diameter (overlay),and then it crashed.Now,just when i click/tap at the slider to change the value, it suddenly crashes.As a result I have a warning 'MKMapView' may not respond to '-addCircleWithRadius:'.What am I doing wrong?I am posting the code too.

- (void)handleLongPress:(UIGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state != UIGestureRecognizerStateBegan)
    return;

CGPoint touchPoint = [gestureRecognizer locationInView:mapview];    
CLLocationCoordinate2D touchMapCoordinate = [mapview convertPoint:touchPoint toCoordinateFromView:mapview];

//add pin where user touched down...
MKPointAnnotation *pa = [[MKPointAnnotation alloc] init];
pa.coordinate = touchMapCoordinate;
pa.title = @"Kerkim me baze rrethin";
[mapview addAnnotation:pa];
[pa release];
tmC = touchMapCoordinate;

double radius = 500.0;

MKCircle *circle = [MKCircle circleWithCenterCoordinate:tmC radius:radius];
[mapview addOverlay:circle];

}

- (void)addCircleWithRadius:(double)radius
{
MKCircle *circle = [MKCircle circleWithCenterCoordinate:tmC radius:radius];
[mapview addOverlay:circle];
[circle release];
}

- (IBAction)sliderChanged:(UISlider *)sender
{
[mapview removeOverlays:[mapview overlays]];    
double radius = (sender.value);
[mapview addCircleWithRadius:radius];//Here appears the warning,this is the order of my code.
}
Hari
  • 1,509
  • 15
  • 34

1 Answers1

2

The MKMapView class doesn't have an addCircleWithRadius: method – that method is part of the class you wrote, so you should probably be calling [self addCircleWithRadius:radius] instead.

Scott Forbes
  • 7,397
  • 1
  • 26
  • 39
  • Yes and remove `[circle release];` from that method since `circle` will be autoreleased. –  Oct 18 '11 at 14:47
  • Thanks! The problem is now resolved.I did remove also the `[circle release];`.But,may I ask another question since is related to this code?It happens like in the question [MKOverlay not resizing smoothly](http://stackoverflow.com/questions/4876035/mkoverlay-not-resizing-smoothly), the overlay doesn't resize smoothly at all.Sometimes, when the slider is at large value position the overlay even disappears.I must place it at lower values and than again in that position for it to be viewable.What might it be? – Hari Oct 18 '11 at 15:01