UICalloutView willRemoveSubview:]:發送到釋放實例的消息;標註按鈕崩潰的應用程序 - MapKit
只有當我點擊標註按鈕時,纔會發生這種情況,但不是第一次,也不是第2次,而是第3次。所以我點擊自定義AnnotationView
,標註彈出,這很好。我再次點擊它,標註彈出,都很好。我點擊另一個,轟然消失。它只會發生,如果設置正確的accesoryview是一個按鈕。
要記住的一個關鍵方面..只發生在iOS 6 ...(去圖)。
我真的被困在這一個 - 一些幫助,將不勝感激。
if ([annotation isKindOfClass:[RE_Annotation class]])
{
RE_Annotation *myAnnotation = (RE_Annotation *)annotation;
static NSString *annotationIdentifier = @"annotationIdentifier";
RE_AnnotationView *newAnnotationView = (RE_AnnotationView *)[mapViews dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if(newAnnotationView)
{
newAnnotationView.annotation = myAnnotation;
}
else
{
newAnnotationView = [[RE_AnnotationView alloc] initWithAnnotation:myAnnotation reuseIdentifier:annotationIdentifier];
}
return newAnnotationView;
}
return nil;
此外,這是我的initwithannotation
方法:
- (id)initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
if(self)
{
RE_Annotation *myAnnotation = annotation;
self = [super initWithAnnotation:myAnnotation reuseIdentifier:reuseIdentifier];
self.frame = CGRectMake(0, 0, kWidth, kHeight);
self.backgroundColor = [UIColor clearColor];
annotationView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"map_pin_pink.png"]];
annotationView.frame = CGRectMake(0, 0, kWidth - 2 *kBorder, kHeight - 2 * kBorder);
[self addSubview:annotationView];
[annotationView setContentMode:UIViewContentModeScaleAspectFill];
self.canShowCallout = YES;
self.rightCalloutAccessoryView = [[UIButton buttonWithType:UIButtonTypeInfoLight] retain]; ///if i take it out it doesnt crash the app. if i leave it it says that message
}
return self ;
}
你能告訴我們你正在使用的代碼嗎?沒有看到你在做什麼是不可能的。 –
我的代碼太長以至於不適合:( – user1878326
)不要發佈所有代碼,只是相關部分,例如處理地圖註釋的代碼。 –