gpt4 book ai didi

ios - DidSelect 注解被调用

转载 作者:行者123 更新时间:2023-12-01 16:31:28 37 4
gpt4 key购买 nike

我有一个点击手势识别器添加到 mapView。我的 MapView 有注释,当我只点击注释时 dismissCollectionView叫做。 DidSelectAnnotation 方法没有被调用。当我点击注释时,如何停止 tapgesture 方法(dismisscollection)调用?任何帮助将不胜感激。

self.m_mapView = [[MKMapView alloc] init];
self.m_mapView.frame = CGRectMake(0, 0, 320, 568);
self.m_mapView.delegate = self;

// MapHeight = self.m_mapView.frameHeight;

m_locationManager = [[CLLocationManager alloc] init];

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
[m_locationManager requestWhenInUseAuthorization];
[m_locationManager requestAlwaysAuthorization];
}
self.m_mapView.mapType = MKMapTypeStandard;
[self.m_mapView setUserTrackingMode:MKUserTrackingModeFollow];
[self.m_bgImageView addSubview:self.m_mapView];

m_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
m_locationManager.delegate = self;


UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismissCollectionView)];
tapGesture.numberOfTouchesRequired = 1;
tapGesture.cancelsTouchesInView = NO;
[self.m_mapView addGestureRecognizer:tapGesture];

最佳答案

如果您希望这两种操作都发生 : 设置手势识别器的代理并实现 gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: 返回 YES用于您的识别器和 map View 内部使用的任何识别器。

如果你想要dismissCollectionViewmapView:didSelectAnnotationView:互斥 : 实现 -gestureRecognizer:shouldReceiveTouch: 并检查触摸位置是否在 MKAnnotationView或其 subview 之一。只返回YES如果该位置在所有注释 View 之外。

关于ios - DidSelect 注解被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31483016/

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