У меня проблема с дополнительными представлениями в MKAnnotationView
s, но это происходит только при использовании iOS 3 SDK.В частности, версия 3.1.3.
У меня есть подкласс MKAnnotationView
, и я создаю его экземпляры обычным способом:
SourceAnnotationView *annotationView = (SourceAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:kDefaultSourceAnnotationID];
if (annotationView == nil) {
#if DEBUG
NSLog(@"RecordViewController viewForAnnotation source %d",[sourceAnnotation.ioiIdent intValue]);
#endif
annotationView = [[[SourceAnnotationView alloc] initWithAnnotation:sourceAnnotation reuseIdentifier:kDefaultSourceAnnotationID] autorelease];
annotationView.delegate = self;
}
Позже в коде я изменяю содержимоепузыря выноски, выполнив:
UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
[deleteButton setImage:[UIImage imageNamed:kDeleteAudioButtonImageName] forState:UIControlStateNormal];
deleteButton.frame = CGRectMake(0, 0, kAnnotationViewLeftAccessoryWidth, kAnnotationViewLeftAccessoryHeight);
deleteButton.tag = kDeleteAudioButtonTag;
deleteButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
deleteButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[deleteButton addTarget:self action:@selector(calloutButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
selectedAnnotationView.leftCalloutAccessoryView = deleteButton;
UIButton *editAudioInfoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
editAudioInfoButton.frame = CGRectMake(0, 0, kAnnotationViewRightAccessoryWidth, kAnnotationViewRightAccessoryHeight);
editAudioInfoButton.tag = kEditInfoButtonTag;
editAudioInfoButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
editAudioInfoButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[editAudioInfoButton addTarget:self action:@selector(calloutButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
selectedAnnotationView.rightCalloutAccessoryView = editAudioInfoButton;
с kAnnotationViewRightAccessoryWidth
и kAnnotationViewRightAccessoryHeight
равными 32.
Когда мне больше не нужны эти кнопки, я пытаюсь (и в большинствекейсы), чтобы избавиться от них так:
selectedAnnotationView.rightCalloutAccessoryView = nil;
selectedAnnotationView.leftCalloutAccessoryView = nil;
В iOS 4 это приводит к исчезновению вспомогательных представлений и все работает прекрасно.Однако в iOS 3 две кнопки остаются, даже если они не активируются, как если бы они не были полностью удалены из вида выноски.
Кроме того, если я нажимаю любой другой вид аннотации, появляются две кнопки.
Кто-нибудь знает, как решить эту проблему?
Спасибо!
РЕДАКТИРОВАТЬ:
Вот изображение того, что происходит:
![enter image description here](https://i.stack.imgur.com/l9dat.jpg)