gpt4 book ai didi

iphone - 向 UIMapView 添加可点击注释

转载 作者:行者123 更新时间:2023-12-03 18:54:25 26 4
gpt4 key购买 nike

我想向带有公开按钮的 MapView 添加注释,但我无法弄清楚。

我创建了一个符合 MKAnnotation 协议(protocol)的 PlaceMark 类,然后创建 MapView 并添加 PlaceMark:

// Add annotation information
PlaceMark *venuePlacemark = [[PlaceMark alloc] initWithCoordinate:location];
venuePlacemark.locationTitle = [locationDictionary valueForKey:VENUE_NAME_KEY];
venuePlacemark.locationSubtitle = @"Touch to show in Google Maps";

// Create the accessory button on the placemark
[venueMap addAnnotation:venuePlacemark];
[venueMap setRegion:region animated:TRUE];
[venueMap regionThatFits:region];

这一切都有效,并且会显示一个图钉,触摸时会显示正确的标注文本。我不知道如何在调用中添加披露按钮。抱歉,如果这是初级的,我们将不胜感激。

戴夫

最佳答案

我想我已经弄清楚了...实现了以下委托(delegate)方法:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKPinAnnotationView *dropPin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"venues"];

UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[disclosureButton addTarget:self action:@selector(mapCallOutPressed:) forControlEvents:UIControlEventTouchUpInside];

dropPin.rightCalloutAccessoryView = disclosureButton;
dropPin.animatesDrop = YES;
dropPin.canShowCallout = YES;

return dropPin;
}

关于iphone - 向 UIMapView 添加可点击注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1856399/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com