2011-04-26 73 views
0

您好,我正在尝试创建一个可拖动的图钉,但是当我试图移动图钉时,只有地图移动和引脚停留在缩略位置,我做错了什么。可拖动的地图视图pin

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{ 

    MKPinAnnotationView *test=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"parkingloc"]; 
    if([annotation title][email protected]"Parked Location") 
    { 
//  
     [test setUserInteractionEnabled:YES]; 
     [test setCanShowCallout:YES]; 
     [test setDraggable:YES]; 
     return test;  
    } 
    [ 
    return test;  
} 

也是我的自定义annonation类是像这些

- (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; 
} 

,但它不工作,为什么......?

+0

找到解决方案? – Melvin 2011-12-14 15:56:48

+0

fount它,请参阅readwrite属性的答案:http://stackoverflow.com/questions/5061976/mapview-annotation-not-dragging – Melvin 2011-12-14 16:07:23

回答

1

这是旧的,但柜面任何人有兴趣在未来:

如果没有|标题|为MKPinAnnotationView设置,拖动也不起作用。