【发布时间】:2017-06-30 03:03:41
【问题描述】:
我想在单击地图点时获取地图注释索引号,但我遇到了一个问题,即当我第一次运行应用程序并单击显示索引 = 5 的点时。但是当我重新运行应用程序并再次单击同一点,它显示 index = 23。在我重新运行应用程序后,索引号不断变化,它不会在我单击的确切点显示相同的索引号。
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
if ([view.annotation isKindOfClass:[MKPointAnnotation class]]) {
NSUInteger index = [mapView.annotations indexOfObject:view.annotation];
NSLog(@"Index number is %lu", (unsigned long)index);
}
【问题讨论】:
-
@ElTomato 我需要 objc 谢谢
标签: ios objective-c annotations mkmapview mkannotationview