简体   繁体   English

Mapview上的可拖动销

[英]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 mi doing wrong. 嗨,我正在尝试创建可拖动的图钉,但是当我尝试移动图钉时,它不会移动,仅地图会移动,而图钉仍停留在smae位置,这是我做错的。

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)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. 为MKPinAnnotationView设置,则拖动也不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM