iPhone-使用UITableview didSelectRowAtIndexPath方法显示覆盖图

iPhone-使用UITableview didSelectRowAtIndexPath方法显示覆盖图,iphone,overlay,tableview,Iphone,Overlay,Tableview,您好, 我已经进入iOS只有1.5个月了,我希望我没有问一个已经在这里回答过的问题。这是: 我有一个tableview,它列出了一些持续时间,每个持续时间都属于一个覆盖,包含带有时间戳的坐标: for (NSUInteger i = 0; i < [dataset count]; i++) { crumbPath = [[CrumbPath alloc] initWithCenterCoordinate:mapView.userLocation.coordin

您好, 我已经进入iOS只有1.5个月了,我希望我没有问一个已经在这里回答过的问题。这是:

我有一个tableview,它列出了一些持续时间,每个持续时间都属于一个覆盖,包含带有时间戳的坐标:

for (NSUInteger i = 0; i < [dataset count]; i++)
    {   
        crumbPath = [[CrumbPath alloc] initWithCenterCoordinate:mapView.userLocation.coordinate]; //crumbPath is my overlay

        NSDictionary *route = [dataset objectAtIndex:i];
        NSArray *points = [route objectForKey:@"Points"];

        for (NSUInteger j = 0; j < [points count]; j++)
        {
            NSDictionary *point = [points objectAtIndex:j];

            float latitude = (float)([[point objectForKey:@"Latitude"] doubleValue]/1000000);
            float longitude = (float)([[point objectForKey:@"Longitude"] doubleValue]/1000000);

            CLLocationCoordinate2D tempCoord = CLLocationCoordinate2DMake(latitude, longitude);

            [crumbPath addCoordinate:tempCoord];
        }
        [mapView addOverlay:crumbPath];
        [crumbPath release];
    }
for(整数i=0;i<[数据集计数];i++)
{   
crumpPath=[[crumpPath alloc]initWithCenterCoordinate:mapView.userLocation.coordinate];//crumpPath是我的覆盖
NSDictionary*route=[dataset objectAtIndex:i];
NSArray*点=[route objectForKey:@“点];
对于(整数j=0;j<[点数];j++)
{
NSDictionary*point=[points objectAtIndex:j];
浮动纬度=(浮动)([[point objectForKey:@“latitude”]doubleValue]/1000000);
浮点经度=(浮点)([[point objectForKey:@“经度”]doubleValue]/1000000);
CLLocationCoordinate2D tempCoord=CLLocationCoordinate2D(纬度、经度);
[坐标:tempCoord];
}
[地图视图添加覆盖:路径];
[路径释放];
}
据我所知,我可以在我的tableview上列出持续时间,我现在想做的是,使用tableview:didSelectRowAtIndexPath方法,我猜,显示在tableview上点击持续时间的覆盖。现在,我的覆盖图都显示在mapview上,我只想显示选中的覆盖图

提前谢谢


Ali

-(void)removeOverlay:(id)overlay
可用于删除您不想再显示的内容。

-(void)removeOverlay:(id)overlay
可用于删除您不想再显示的内容。

发布我对我忘记的问题的答案

tableView:didSelectRowAtIndexPath:
中,我只是先删除了所有覆盖,然后添加了从tableView中获取索引的所选覆盖

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     [self.mapView removeOverlays:crumbs]; //crumbs - overlay array
     [self.mapView addOverlay:[crumbs objectAtIndex:[indexPath row]]];
}

发布我对我忘记的问题的答案

tableView:didSelectRowAtIndexPath:
中,我只是先删除了所有覆盖,然后添加了从tableView中获取索引的所选覆盖

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     [self.mapView removeOverlays:crumbs]; //crumbs - overlay array
     [self.mapView addOverlay:[crumbs objectAtIndex:[indexPath row]]];
}

谢谢你的回复。我很快就在didSelectRowatinex方法中使用了一个数组找到了我的解决方案。感谢您的回复。我很快在didSelectRowatinex方法中使用了一个数组找到了我的解决方案。