如何操作选择添加到上标注视图弹出气泡 [英] How to add Action selector to the popup bubble on Annotation view

查看:308
本文介绍了如何操作选择添加到上标注视图弹出气泡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很新的MapKit实施

I have very new to MapKit Implementation

在我的应用程序在一个页面是成为地图

In my app one page is to be map View

在我所显示的引脚及其注释动作的散装量。

in that I have displayed bulk amount of pins and their Annotation actions.

我添加了一个披露按钮的 的和波纹管所示的弹出气泡,这些披露的按钮设置的动作。

我想同样的行动当上灰色的泡沫自来水

//To add a discloser button to show route map
        UIButton *detailBtn=[UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        pinView.rightCalloutAccessoryView=detailBtn;
        [detailBtn addTarget:self action:@selector(showRoute:) forControlEvents:UIControlEventTouchUpInside];
        DisplayMap *ann=(DisplayMap *)annotation;
        detailBtn.tag = ann.detailButtonTag;



//viewForAnnotation DELEGATE for annotions
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
(id <MKAnnotation>)annotation {
    MKPinAnnotationView *pinView = nil;
    if(annotation != mapView.userLocation)
    {
        static NSString *defaultPinID = @"com.invasivecode.pin";
        pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
        if ( pinView == nil ) pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] ;
        pinView.pinColor = MKPinAnnotationColorRed;
        pinView.canShowCallout = YES;
        pinView.animatesDrop = YES;

        //To add a discloser button to show route map
        UIButton *detailBtn=[UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        pinView.rightCalloutAccessoryView=detailBtn;
        [detailBtn addTarget:self action:@selector(showRoute:) forControlEvents:UIControlEventTouchUpInside];
        DisplayMap *ann=(DisplayMap *)annotation;
        detailBtn.tag = ann.detailButtonTag;
    }
    else
    {
        [mapView.userLocation setTitle:@"I am here"];
    }
    return pinView;
}

但我想同样的行动当上灰色的泡沫水龙头..

But i Want to Same action When tap on that gray bubble..

该怎么办呢

how to do it

推荐答案

有两种方法,在<一个href=\"http://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapViewDelegate_Protocol/MKMapViewDelegate/MKMapViewDelegate.html\"相对=nofollow> MKMapViewDelegate :

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view

有关如何使用这些方法的更多详细信息,您可以检查罗布答案

For more detail on how to use these methods, you can check the Answer by Rob.

更新:

有关,您可以使用自定义标注。您可以创建自定义按钮与showRoute的方法,并添加作为一个子视图到自定义标注内容的浏览。

For that you can use Custom Callout. You can create Custom Button with the "showRoute" methods and add as a Sub view to the Custom Callout Content View.

这篇关于如何操作选择添加到上标注视图弹出气泡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆