2012-04-26 33 views
0

我有代碼:MapKit addAnnotations:不工作

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 在此代碼之前,我有下一個日誌記錄的東西:

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

我錯過了什麼嗎?

回答

6

我覺得這是一個小錯誤,

這一行:

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

應該是:

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

羞辱我。 謝謝 – Uko 2012-04-27 08:21:29