0
我已經實現了自定義MKAnnotationView,並且在啓用ARC之前它正常工作。 initWithAnnotation方法來實現這樣的:自定義MKAnnotationView在啓用ARC之後停止工作
- (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;
目前我不知道會發生什麼。
我從如何創建自定義可拖動引腳的示例中獲取此代碼。它運行良好,直到我啓用ARC。但花了一些時間後,我解決了這個問題,用「self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifyer]」替換「self =(AnnotationView *)pinAnnView」 – Misha 2012-04-28 11:29:41