0

我正在研究 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; 
}
4

1 回答 1

0

我解决了这个问题,这是因为引脚一次又一次地重绘,因为 [location manager stopUpdatingLocation] 无法正常工作。所以使用 bool 变量我停止调用一次又一次初始化 Mapview 的类。

@aBitObvious:非常感谢您的支持,谢谢...

于 2011-01-20T08:54:32.960 回答