【问题标题】:Reload mapView with new pins iphone dev?使用新引脚 iphone dev 重新加载 mapView?
【发布时间】:2011-10-31 05:25:43
【问题描述】:

我正在开发一个应用程序,我需要在其中同时显示多个事件位置,并且我有两种类型的事件(我的事件和所有事件)。我有机会通过段控制在我的事件和所有事件之间切换,首先它显示所有事件位置,当用户切换到我的事件时,它将删除或隐藏所有事件位置(引脚)并在同一地图视图上显示我的事件位置引脚.我有点困惑如何处理这个重新加载或使用新引脚刷新地图视图?

【问题讨论】:

    标签: iphone mkmapview


    【解决方案1】:

    你可以试试这个……

        //Remove or hide all annotations
    for (id annotation in mapView.annotations) {
        if (annotation != mapView.userLocation) {
            [[mapView viewForAnnotation:annotation] setHidden:YES]; // You can remove as well
        }
    }
    

    /删除注释而不是隐藏的代码/

        NSMutableArray *listRemoveAnnotations = [[NSMutableArray alloc] init];
    for (id annotation in mapView.annotations) {
        if (annotation != mapView.userLocation) {
            [listRemoveAnnotations addObject:annotation];
        }
    }
    [mapView removeAnnotations:listRemoveAnnotations];
    [listRemoveAnnotations release];
    

    当所有注解都处理完毕后:

    • 如果所有注释都已隐藏,请取消隐藏您要显示的注释。
    • 如果删除了所有注释,请添加您希望显示的注释。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-09
      • 2022-12-04
      • 2012-03-27
      相关资源
      最近更新 更多