我正在使用 plist 中的数据在地图上加载一堆图钉。这是我获取数据的方式:
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 ?