当我添加一个注解时,我会给它添加一个".tag“。但是,我永远不能用下面的方法读取标记。
`- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation`
MKAnnotationView *annView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MyPin"];
annView.canShowCallout = YES;
NSLog(@"annView.tag = %d", annView.tag);
return annView;
}NSLog始终为0。有谁能解释一下这件事吗?
值得一提的是,如果我使用NSLog注释,我确实会看到标签。
2010-09-10 10:21:27.612 [1328:207] annotation = <BarPin: 0xdbfa5b0; frame = (0 0; 0 0); tag = 99; layer = <CALayer: 0xdbfa680>>发布于 2010-09-11 02:35:33
您可能在注释上设置了tag属性,并试图在注释视图上读回它。
此外,看起来您的代码片段正在泄漏annView;您可能想要自动释放它。
https://stackoverflow.com/questions/3685312
复制相似问题