我正在开发具有 map View 功能的应用程序。我想在 mapview 上显示自定义图钉图像,单击带有图像和标题的打开的自定义标注气泡。单击该标注气泡 View ,我想执行一些功能。如何做到这一点?任何帮助将不胜感激
最佳答案
前往 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;
}
关于ios - 自定义标注气泡 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22110423/