我已经实现了自定义 MKAnnotationView,并且在启用 ARC 之前它工作正常。initWithAnnotation 方法是这样实现的:
- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier
{
self.hasBuiltInDraggingSupport = [[MKAnnotationView class] instancesRespondToSelector:NSSelectorFromString(@"isDraggable")];
if (self.hasBuiltInDraggingSupport)
{
MKPinAnnotationView *pinAnnView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
self = (AnnotationView*)pinAnnView;
if (self)
[self performSelector:NSSelectorFromString(@"setDraggable:") withObject:[NSNumber numberWithBool:YES]];
}
self.canShowCallout = YES;
return self;
}
启用 ARC 后,我开始在以下行中收到 EXC_BAD_ACCESS:
self = (AnnotationView*)pinAnnView;
目前我不知道会发生什么。