我正在使用 GMSMapview,当我在 map 上实现单击手势时,它无法正常工作。我该怎么做?
tapRec = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(mapDidTap:)];
tapRec.delegate = self;
tapRec.numberOfTapsRequired = 1;
[mapView2 addGestureRecognizer: tapRec];
和
-(void)mapDidTap:(UITapGestureRecognizer *)gestureRecognizer
{
[mapView2 removeGestureRecognizer:tapRec];
_filterView.hidden = YES;
}
最佳答案
您不需要添加点击手势。 GMSMapView 提供了自己的方法来检测特定纬度/经度上的点击。
func mapView(mapView: GMSMapView, didTapAtCoordinate coordinate: CLLocationCoordinate2D) {
//Coordinates where user has tapped
print(coordinate)
}
关于ios - 添加单击识别器在 GMSMapview 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39467687/