2011-04-26 71 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設置,拖動也不起作用。