【问题标题】:MKMapView selectAnnotation methodMKMapView selectAnnotation 方法
【发布时间】:2014-07-01 03:39:22
【问题描述】:

我有一张桌子并按下一个单元格,我想查看相关的引脚,我该怎么做?

我有这个代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

[_mapView selectAnnotation:[_mapView.annotations objectAtIndex:indexPath.row] animated:true];

}

问题是它打开了另一个不相关的引脚,我该怎么办?

【问题讨论】:

  • 那么问题可能出在_mapView.annotations 数组或确保indexPath.row OR indexPath.section
  • 地图视图的annotations数组的顺序不保证。见stackoverflow.com/questions/9539802/…stackoverflow.com/questions/13017305/…
  • 您的表格视图必须使用某些数据源。在该数据源中,您可以保留对相关注释对象的引用(或者您的数据源对象注释)。
  • 非常感谢!我有这个代码来解决它

标签: ios uitableview mkmapview mkannotationview


【解决方案1】:
int valor =0;

for (MKPointAnnotation *annotation in _mapView.annotations){

  if ([_propLabel.text isEqual:annotation.subtitle]) {      
     [_mapView selectAnnotation:[_mapView.annotations objectAtIndex:valor] animated:true];

    }

    valor++;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-23
    • 1970-01-01
    • 2010-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多