yandexmobile / yandexmapkit-ios

Yandex Map Kit for iOS
Other
173 stars 30 forks source link

Некорректно работает dequeueReusableAnnotationViewWithIdentifier:(NSString *)identifier; #113

Open exxbrain opened 11 years ago

exxbrain commented 11 years ago

К сожалению не могу указать конкретные шаги воспроизведения, но после добавлений, удалений и перемещений в какой-то момент перестают отображаться только что добавленные аннотации с помощью


- (void)addAnnotation:(id)annotation;

Есть предположение, что это связано с некорректной работой метода


- (YMKAnnotationView *)dequeueReusableAnnotationViewWithIdentifier:(NSString *)identifier;

Т.к. после отказа от переиспользования Annotation View в методе


- (YMKAnnotationView *)mapView:(YMKMapView *)aMapView viewForAnnotation:(id)anAnnotation;

Заработало

iohin commented 11 years ago

Столкнулся с этой же проблемой, сначала тоже отказался от реюза, но потом до меня дошло, что реюзабельной вьюшке аннотации необходимо передать актуальную аннотацию. То есть что-то вроде того

- (YMKAnnotationView *)mapView:(YMKMapView *)sender viewForAnnotation:(id<YMKAnnotation>)annotation
{
    static NSString * const kAnnotationId = @"myAnnotation";

    YMKAnnotationView *annotationView = (YMKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:kAnnotationId];
    if (annotationView == nil) {
        annotationView = [[YMKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:kAnnotationId];
    } else {
        [annotationView setAnnotation:annotation];
    }

    return annotationView;
}

Теперь реюз работает нормально после удаления/добавления