gpt4 book ai didi

ios - 在 MKAnnotationView 中检测点击 CalloutBubble

转载 作者:IT王子 更新时间:2023-10-29 07:55:46 26 4
gpt4 key购买 nike

我正在使用 MKMapView 和 MKAnnotationView。

我在 map 上有一个注释。当用户点击它时,会显示 callOut 气泡。当再次点击注释时(并且 callOut 气泡可见),我需要切换到另一个 View 。

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

最佳答案

在初始化 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;
}

关于ios - 在 MKAnnotationView 中检测点击 CalloutBubble,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3395772/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com