2012-01-31 25 views
0

我正在創建一個應用程序,它從服務器中提取數據並在地圖上查明不同的房屋。我的問題是,它確實顯示了註釋,但是當我點擊它們時,它們沒有響應。 - (void) :MKMapAnnotations didSelectAnnotationView沒有迴應

int s; 
self.mapAnnotations = [[NSMutableArray alloc] init]; 

for(s=0; s < numberOfAnnotations; s++) 
{ 
    //NSDictionary *dict2 = [parser objectWithString:[[arrayOfResults objectAtIndex:0] description]]; 

    CLLocationDegrees daLong = [[[[[arrayOfResults objectAtIndex:s] objectForKey:@"map"] objectForKey:@"longitude"] description] floatValue]; 
    CLLocationDegrees daLat = [[[[[arrayOfResults objectAtIndex:s] objectForKey:@"map"] objectForKey:@"latitude"] description] floatValue]; 

    /*self.customAnnotation = [[BasicMapAnnotation alloc] initWithLatitude:daLat andLongitude:daLong]; 
    [self.mapView addAnnotation:self.customAnnotation];*/ 

    BasicMapAnnotation *m = [[BasicMapAnnotation alloc] initWithLatitude:daLat andLongitude:daLong]; 
    [self.mapAnnotations addObject:m]; 


} 

[self.mapView addAnnotations:self.mapAnnotations]; 
NSLog(@"this number of annotations %d", [self.mapAnnotations count]); 

我也注意到,當我創建了一個單獨的房子放在我的viewDidLoad中上圖:

self.normalAnnotation = [[BasicMapAnnotation alloc] initWithLatitude:38 andLongitude:-90.2045]; 
self.normalAnnotation.title = @"               "; 
[self.mapView addAnnotation:self.normalAnnotation]; 

它沒有工作時,我點擊它,而是通過數組傳遞的那些沒沒有工作。 任何人都可以幫我弄清楚爲什麼它沒有響應?

回答

4

這是因爲註釋應該有一個title爲他們顯示標註。在您的for循環中,像self.normalAnnotation.title = @" "一樣設置title屬性。

+2

非常感謝!我不認爲這會是問題! – bakwarte 2012-01-31 00:43:23