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