如何解决MKMapView多个注释调出按钮以显示详细视图
| 我正在通过使用http://www.totagogo.com/2011/02/08/google-local-search-ios-code/这个应用程序开发用于餐厅等本地搜索的应用程序,应用按钮以调用注释以通过导航到另一个detailViewController提取细节。请通过提供一些教程/示例代码来帮助我克服此问题。解决方法
我找到了解决方案
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(GoogleLocalObject *) annotation
{
static NSString* AnnotationIdentifier = @\"AnnotationIdentifier\";
MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];
customPinView.pinColor = MKPinAnnotationColorRed;
customPinView.animatesDrop = YES;
customPinView.canShowCallout = YES;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
customPinView.rightCalloutAccessoryView = rightButton;
UIImageView *memorialIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@\"googlemaps_pin.png\"]];
customPinView.leftCalloutAccessoryView = memorialIcon;
[memorialIcon release];
return customPinView;
}
- (void)showDetails:(id)sender {
GoogleLocalObject *obj;
for (int i = 0; i < [objectsFromGoogle count]; i++) {
obj = [objectsFromGoogle objectAtIndex:i];
}
self.reverseGeocoder =
[[[MKReverseGeocoder alloc] initWithCoordinate:obj.coordinate] autorelease];
reverseGeocoder.delegate = self;
[reverseGeocoder start];
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。