使用WhirlyGlobe删除标签

时间:2011-10-11 20:01:02

标签: iphone objective-c ios cocoa-touch

我在新应用程序中使用(非常酷)WhirlyGlobe(https://code.google.com/p/whirlyglobe/)3D全球显示屏。我可以使用下面显示的代码在特定位置添加标签。我希望能够返回并删除我之前添加的标签。文档(http://whirlyglobedocs.s3-website-us-east-1.amazonaws.com/html/interface_label_layer.html#ac17e1ec72e70eec416cb2cac833f46fa)显示了一个removeLabel方法,但我似乎无法使其工作。我可以添加但不删除标签。我尝试循环遍历所有子视图但无法找到这些SimpleLabel实例。有人可以帮我理解如何删除标签吗?我找到很多例子并没有太多运气。谢谢!

// Current position
float lat = [[values objectAtIndex:8] floatValue];
flaot lon = [[values objectAtIndex:9] floatValue];

// Create a SingleLabel at this Lat / Lon pair location                
SingleLabel *interimLabel = [[[SingleLabel alloc] init] autorelease];
interimLabel.text = [NSString stringWithFormat:@"PRN %d",[[values objectAtIndex:1] intValue]];
[interimLabel setLoc:GeoCoord::CoordFromDegrees(lon, lat)];
[locationArray addObject:interimLabel];
[allLabels addObject:interimLabel];

1 个答案:

答案 0 :(得分:0)

当您向标签图层添加单个标签或一组标签时,您将获得SimpleIdentity。把它放在某个地方。然后,当您想要从标签图层中删除标签(或标签组)时,您将返回该SimpleIdentity。

这是怎么回事。 WhirlyGlobe批量绘制可绘制的数据,如mofo。一旦标签层将它们碾压成尽可能少的Drawables,它的SingleLabel对象就不再存在了。因此,要引用这些标签,您必须保留唯一ID。

现在,如果您想单独删除这些标签或单独更改它们的外观,那么您必须逐个添加它们。一个标签到一个SimpleIdentity。否则就无法单独引用它们。

对于速度,我建议尽可能多地将它们分组在一起。如果现在这太复杂了,请逐个添加它们,然后记下来回来。因此,当你说“为什么这不是我想要的那么快”时,你可以说“噢,对。”