在MKAnnotationView中检测对CalloutBubble的点击 [英] Detect Tap on CalloutBubble in MKAnnotationView

查看:65
本文介绍了在MKAnnotationView中检测对CalloutBubble的点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MKMapView和MKAnnotationView.

Im working with MKMapView and MKAnnotationView.

我在地图上有一个注释.当用户点击它时,将显示标注气泡.当再次点击注释(并且可以看到callOut气泡)时,我需要切换到另一个视图.

I have an annotation in the map. When the users tap on it, the callOut Bubble is displayed. When the annotation is tapped again ( and the callOut Bubble is visible ) i need to change to another view.

如何检测第二次点击或气泡中的点击?

How can i detect the second tap, or the tap in the bubble?

推荐答案

初始化MKAnnotationView时可以添加手势识别器吗?

Could you add a gesture recognizer when you're initializing the MKAnnotationView?

这是dequeueReusableAnnotationViewWithIdentifier:

UITapGestureRecognizer *tapGesture = 
        [[UITapGestureRecognizer alloc] initWithTarget:self 
                                        action:@selector(calloutTapped:)];
[theAnnotationView addGestureRecognizer:tapGesture];
[tapGesture release];

手势识别器的方法:

-(void) calloutTapped:(id) sender { 
    // code to  display whatever is required next.

    // To get the annotation associated with the callout that caused this event:
    // id<MKAnnotation> annotation = ((MKAnnotationView*)sender.view).annotation;
}

这篇关于在MKAnnotationView中检测对CalloutBubble的点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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