0
我使用來自plist的數據在地圖上加載了一堆針腳。這裏是我得到的數據:獲取indexPath for mapView註釋
for (int i=0; i<self.dataArray.count; i++){
NSDictionary *dataDictionary = [self.dataArray objectAtIndex:i];
NSArray *array = [dataDictionary objectForKey:@"Locations"];
for (int i=0; i<array.count; i++){
NSMutableDictionary *dictionary = [array objectAtIndex:i];
double latitude = [[dictionary objectForKey:@"Latitude"] doubleValue];
double longitude = [[dictionary objectForKey:@"Longitude"] doubleValue];
CLLocationCoordinate2D coord = {.latitude =
latitude, .longitude = longitude};
MKCoordinateRegion region = {coord};
MapAnnotation *annotation = [[MapAnnotation alloc] init];
annotation.title = [dictionary objectForKey:@"Name"];
NSString *cityState = [dictionary objectForKey:@"City"];
cityState = [cityState stringByAppendingString:@", "];
NSString *state = [dictionary objectForKey:@"State"];
cityState = [cityState stringByAppendingString:state];
annotation.subtitle = cityState;
annotation.coordinate = region.center;
[mapView addAnnotation:annotation];
}
}
現在對每一個註釋,我添加了一個detailDisclosureButton。我想從plist中顯示特定位置的詳細信息。問題是我需要indexPath.section和indexPath.row。
如何獲得pin的indexPath?有沒有辦法找到填充註釋標題的字典的indexPath?
你的天才!像你解釋的一樣工作。謝謝! – user984248