Draggable pin on mapview
Hi am trying to create a draggable pin , but it not moving when i try to move the pin only the map moves around and the pin stays at the smae position what m i doing wrong.
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotatio开发者_运维问答n>)annotation{
MKPinAnnotationView *test=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"parkingloc"];
if([annotation title]==@"Parked Location")
{
//
[test setUserInteractionEnabled:YES];
[test setCanShowCallout:YES];
[test setDraggable:YES];
return test;
}
[
return test;
}
also my custom annonation class is like these
- (NSString *)subtitle{
return @"Put some text here";
}
- (NSString *)title{
return @"Parked Location";
}
-(id)initWithCoordinate:(CLLocationCoordinate2D) c{
coordinate=c;
NSLog(@"%f,%f",c.latitude,c.longitude);
return self;
}
- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate
{
coordinate=newCoordinate;
}
but its not working why...?
This is old but incase anyone is interested in the future:
If no |title| is set for the MKPinAnnotationView, dragging won't work either.
精彩评论