自定义标注泡泡iO

自定义标注泡泡iO

本文介绍了自定义标注泡泡iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发具有mapview功能的应用。我想在mapview上显示自定义图片图像,点击该图片和标题打开的自定义标注气泡。点击该标注气泡视图,我想做一些功能。怎么做到这一点?任何帮助将不胜感激

I am developing app with mapview functionality. I want to show custom pin image on mapview, click on that open custom callout bubble with image and title. With click on that callout bubble view I would like to do some functionality. How to achieve this? Any help will be appreciated

推荐答案

前往 用于自定义控件。我打赌你会发现一些对你的要求有用的东西。

Head over to CocoaControls for custom controls. I bet you'll find something useful for your requirement.

以下是CocoaControls的一些搜索结果:

Here are some search results from CocoaControls:





  • Callout
  • Bubble
  • Popup

SO上已有问题可以回答这个 等等。我敢说你会在他们中找到答案。基本上,代码是

There are already questions on SO which answer this here and here and many more. I daresay you'll find your answer among them. Basically, the code is

- (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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 06:48