Я загружаю данные из массива и сбрасываю контакты для записей с указанным местоположением.Я делаю это в моем методе viewWillAppear.
Я добавляю контакты, инициализируя аннотации для указанных записей, а затем добавляя их через
[userLocation addAnnotations: annotations];
Однако я заметил, что все еще могу перетаскивать контакты.Есть ли способ предотвратить перетаскивание контактов из их предопределенного положения?Спасибо за вашу помощь.
viewWillAppear:
for(d=0;d<[eventArray count];d++){
Entry *element=[eventArray objectAtIndex:d];
float lon=[tmp.lon floatValue];
float lat=[tmp.lat floatValue];
if(lon!=0 && lat!=0){
CLLocationCoordinate2D coord = {lat, lon};
MyAnnotation *annotation=[[MyAnnotation alloc]initWithCoordinate:coord title:@"A pin"];
[userLocation addAnnotations: annotations];
}
}
А затем, как предложено:
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
MyAnnotation *annotationView = (MyAnnotation *)[self.userLocation dequeueReusableAnnotationViewWithIdentifier:@"Pin"];
if (annotationView == nil) {
annotationView = [[[DDAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Pin"] autorelease];
// annotationView.rightCalloutAccessoryView = nil;
}
annotationView.draggable=NO;
return annotationView;
}