gpt4 book ai didi

ios - MKAnnotationView 点击手势事件未被调用

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:35:13 29 4
gpt4 key购买 nike

代码:

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view

{
if (![view.annotation isKindOfClass:[MKUserLocation class]])
{
CGSize imgSize;
imgSize = [self getImageWidthHeight:[GRAPHICS MAP_ANNOTATION_DETAIL_BG]];
CGFloat Width = 0.0;
CGFloat Height = 0.0;

Width = imgSize.width;
Height = imgSize.height;

callview = [[JoltCalloutCustomView alloc]initWithFrame:CGRectMake((-Width/2) + (view.frameWidth/2), -Height, Width, Height)];
callview.tag = view.tag;

NSDictionary *dicList = [m_arrShopList objectAtIndex:view.tag];
[callview.nameLabel setText:[dicList objectForKey:@"ShopName"]];
[callview.addressLbl setText:[dicList objectForKey:@"ShopStreet"]];
[callview.logoImageView setImage:[GRAPHICS LOGIN_BG_IMAGE]];

UITapGestureRecognizer *annotaionTapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(annotationViewTapped:)];
// annotaionTapGesture.cancelsTouchesInView = NO;
[callview addGestureRecognizer:annotaionTapGesture];

[view addSubview:callview];


}
else{

[mapView deselectAnnotation:view.annotation animated:NO]; //hide callout for current location
}

}

我在 AnnotationView 上添加了 customView。我在 customView 中添加了 tapGesture 事件。当我点击 customView 时,tagesture 事件没有被调用。我的代码有什么问题?任何帮助将不胜感激。提前致谢

最佳答案

我发现有人创建了一个库来显示自定义标注。

真这个,可能对你有帮助,@Sarheesh

DXCustomCallout-ObjCenter link description here

您可以为标注传递任何自定义 View !它还支持 UIControl 的事件。

enter image description here

关于ios - MKAnnotationView 点击手势事件未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32046411/

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