2 つのピン (カスタム ピン) を持つ MapView があります。
両方のピンがドラッグ可能に設定されていますが、私の問題は、それらの 1 つをドラッグする前に、ドラッグを開始する前に最初に選択する必要があることです。これは、画面を 2 回タップすることを意味します。
私はこの答えについて知っていますが、彼はマップ上にピンを 1 つしか持っておらず、一度に 1 つのピンしか選択できないように思われるので、[MyPin setSelected:YES] を設定します。この場合、私を助けません。
助けてくれてありがとう!
//Custom pin on mapview
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
MKAnnotationView *MyPin=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"current"];
MyPin.draggable = YES;
//Get annotaion title to determine what image to use
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc]init];
annotationPoint = annotation;
if([annotationPoint.title isEqualToString:@"user"])
{
MyPin.image = [UIImage imageNamed:@"userLocation_pin"];
MyPin.centerOffset = CGPointMake(-13, -5); //Offset custom image to display at the exact pin point GPointMake([left/right], [up/down]);
}
else if ([annotationPoint.title isEqualToString:@"destination"])
{
MyPin.image = [UIImage imageNamed:@"destination_pin_up"];
MyPin.centerOffset = CGPointMake(-13, -5); //Offset custom image to display at the exact pin point GPointMake([left/right], [up/down]);
}
return MyPin;
}