0

我有代码:

if (self.annotations) [self.mapView addAnnotations:self.mapView.annotations];
NSLog(@"mapView: %@, anos:%@",self.mapView,self.mapView.annotations);

我得到下一个输出表单日志:

2012-04-26 14:35:53.823 FlickrClient[46441:11603] mapView: <MKMapView: 0x79c8b50; frame = (0 0; 320 367); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x79c62b0>>, anos:(
)

据我了解,注释未添加mapView 到此代码之前的 Also 中,我有下一个日志记录内容:

for (id i in self.annotations)
{
    NSLog(@"%@, %i",i,[i conformsToProtocol:@protocol(MKAnnotation)]);
}

它给出了:

...
2012-04-26 14:35:53.766 FlickrClient[46441:11603] <TopPlaceAnnotation: 0x6d8a590>, 1
2012-04-26 14:35:53.767 FlickrClient[46441:11603] <TopPlaceAnnotation: 0x6d8a5a0>, 1
2012-04-26 14:35:53.767 FlickrClient[46441:11603] <TopPlaceAnnotation: 0x6d8a5b0>, 1
2012-04-26 14:35:53.819 FlickrClient[46441:11603] <TopPlaceAnnotation: 0x6d8a5c0>, 1
2012-04-26 14:35:53.819 FlickrClient[46441:11603] <TopPlaceAnnotation: 0x6d8a5d0>, 1
2012-04-26 14:35:53.819 FlickrClient[46441:11603] <TopPlaceAnnotation: 0x6d8a5e0>, 1
...

所以self.annotations存在并且都符合MKAnnotation

我错过了什么吗?

4

1 回答 1

6

我认为有一个小错误,

这一行:

if (self.annotations) [self.mapView addAnnotations:self.mapView.annotations];

应该:

if (self.annotations) [self.mapView addAnnotations:self.annotations];
于 2012-04-26T11:59:02.247 回答