Ios 如何从NSArray在MKMapView中添加坐标?
我有一个表视图,其中大约有5行,一个数组存储纬度,另一个数组存储经度Ios 如何从NSArray在MKMapView中添加坐标?,ios,objective-c,mkmapview,Ios,Objective C,Mkmapview,我有一个表视图,其中大约有5行,一个数组存储纬度,另一个数组存储经度 现在,如果选择第二行,两个数组中的2对象都将被调用并显示在地图上。 有办法做到这一点吗? 或者我必须在不使用数组的情况下手动输入坐标吗?实现UITableViewDelegate的didSelectRowAtIndexPath:,当调用它时,从数组中获取纬度和经度,并向地图添加注释 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSInd
现在,如果选择第二行,两个数组中的2对象都将被调用并显示在地图上。
有办法做到这一点吗?
或者我必须在不使用数组的情况下手动输入坐标吗?
实现UITableViewDelegate的
didSelectRowAtIndexPath:
,当调用它时,从数组中获取纬度和经度,并向地图添加注释
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat latitude = latitudes[indexPath.row];
CGFloat longitude = longitudes[indexPath.row];
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(latitude, longitude);
MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
point.coordinate = coordinate;
point.title = @"Title";
[self.mapView addAnnotation:point];
}