我正在研究 MKMap View,它根据位置坐标和其他自定义注释显示当前位置。它在 Iphone 3gs 上正确显示,但在 iphone 4.0 或更高版本上,它不会每次都显示自定义注释(随机只显示绿色引脚而不是另一个)。可能是什么问题?ios 4.0及以上有问题吗?如果是这样,我们该如何解决。谁能帮助我
谢谢
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;
}