DidSelect 注释被调用

DidSelect Annotation getting called

我在 mapView 中添加了点击手势识别器。我的 MapView 有注释,当我点击注释时,只会调用 dismissCollectionView。未调用 DidSelectAnnotation 方法。当我点击注释时,如何停止调用手势方法(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: 实现 return YES识别器和地图视图内部使用的任何识别器。

如果想让dismissCollectionViewmapView:didSelectAnnotationView:互斥:实现-gestureRecognizer:shouldReceiveTouch:,检查触摸位置是否在MKAnnotationView 或其子视图之一。只有 return YES 如果该位置在所有注释视图之外。