Custom Callout Bubble iOS

前提是你 提交于 2019-12-09 06:52:13

问题


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


回答1:


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

Here are some search results from CocoaControls:

  • Callout
  • Bubble
  • Popup

Custom Pin Image

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;
}



回答2:


You need to create custom Annotations.

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html




回答3:


Please check out it: https://github.com/grgcombs/MultiRowCalloutAnnotationView

Hope, It will may help you,

:)



来源:https://stackoverflow.com/questions/22110423/custom-callout-bubble-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!