0
我在做mapview。在我的应用程序中有代码获取用户的经纬度当前位置。使用这个坐标我创建一个肥皂请求。作为回应,我将获得位置信息(邮编,城市,州,国家,坐标)。我已经将这些信息保存在NSDictionary中。如何知道哪个已被窃听?
这是创建注释的代码。
MapLocation *annotation = [[MapLocation alloc] initWithCoordinate:location ownerInst:ownerInstitution];
[mapView addAnnotation:annotation];
[annotation release];
- (MKAnnotationView *) mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>) annotation {
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[infoButton addTarget:self action:@selector(infoButtonPressed) forControlEvents:UIControlEventTouchUpInside];
annView.rightCalloutAccessoryView = infoButton;
annView.calloutOffset = CGPointMake(-5, 5);
return annView;
}
这是用户点击标注中的detaildisclosurebutton时的委托方法。
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
在细节揭示按钮的水龙头上将加载新的视图。在这个新视图中,我将从服务器中检索到的信息将会显示出来。
高兴这一切都很好。我在地图上有多个注释。但是,当特定注释被挖掘时,我将如何实现代码以显示与该注释相关的信息(我从服务器获得的信息)。
我希望我在表达我的问题时很清楚。随意问更多的细节。
好的。有多个注释。我将如何进一步实现获取相应的注释信息.http://stackoverflow.com/questions/5583501/assign-dynamic-data-to-detail-view-when-clicking-callout-info-button这是链接它有一个相同的问题。希望你能更清楚地看到这个问题。 – Harsh
是的,我明白你想要什么,但似乎我的答案不清楚。 ;) – yinkou
每次向地图添加注释时,都可以在其中存储自定义信息。我不知道你从哪里得到这些,你必须自己处理。通过扩展您的MapLocation类与方法或属性。 当用户点击calloutAccessory时,您可以在委托方法中将您的信息从此特定注释传递给您的新viewController。 – yinkou