0
我正在MKMap視圖顯示當前位置基於位置座標和其他自定義註釋。它在Iphone 3gs上正確顯示,但在iPhone 4.0或更高版本上,它不會每次都顯示自定義註釋(隨機顯示的只是綠色別針而非其他)。可能是什麼問題? ios 4.0及以上版本有問題嗎?如果是這樣,我們如何解決它。可有人幫我Ios 4 - Mkmap放置自定義註釋問題
感謝
代碼從viewForAnnotation方法...
if ([annotation isMemberOfClass:[MKUserLocation class]])
{
return nil;
}
if (annotation==self.normalAnnotation)
{
NSLog(@"green pin");
MKPinAnnotationView *annotationView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"NormalAnnotation"] autorelease];
annotationView.canShowCallout = NO;
annotationView.pinColor = MKPinAnnotationColorGreen;
return annotationView;
}
else
{
NSLog(@"Custom pin");
Marker *obj = [database getMarkerWithName:[annotation title]];
MKAnnotationView *newAnnotation=[[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annotation1"]autorelease];
newAnnotation.image = [UIImage imageNamed:obj.markerImage];
newAnnotation.canShowCallout=YES;
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[button addTarget:self action:@selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[button setTag:obj.markerID];
newAnnotation.rightCalloutAccessoryView=button;
//annotation.annotationObj = newAnnotation;
return newAnnotation;
}
顯示您的viewForAnnotation方法的代碼。 – Anna 2011-01-19 12:02:05