我正在开发具有mapview功能的应用。我想在mapview上显示自定义图钉图像,点击该图片和标题打开的自定义标注气泡。点击该标注气泡视图,我想做一些功能。怎么做到这一点?任何帮助将不胜感激
答案 0 :(得分:7)
转到 CocoaControls 以获取自定义控件。我打赌你会发现一些对你的要求有用的东西。
以下是CocoaControls的一些搜索结果:
已经有关于SO的问题可以解答 here 和 here 等等。我敢说你会在他们中找到答案。基本上,代码是
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
if([annotation isKindOfClass:[MKUserLocation class]])
return nil;
NSString *annotationIdentifier = @"CustomViewAnnotation";
MKAnnotationView* annotationView = [mapview dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if(!annotationView)
{
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier]];
}
annotationView.image = [UIImage imageNamed:@"map_location_pin.png"];
annotationView.canShowCallout= YES;
return annotationView;
}
答案 1 :(得分:2)
答案 2 :(得分:0)