开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜