ios mapkit closing annotation callouts by tapping the map

后端 未结 2 1185
孤独总比滥情好
孤独总比滥情好 2021-01-05 14:00

I\'ve got a mapkit app that places annotations on the map, when you press them, it shows the callout with the title attribute.

This works fine, but the user cannot c

2条回答
  •  醉酒成梦
    2021-01-05 14:28

    Anna explain good.Also I want to explain with exactly code. You can do like this

         UITapGestureRecognizer *tapMap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeCallout:)];
          [self.mapView addGestureRecognizer:tapMap];
    
    -(void) closeCallout:(UIGestureRecognizer*) recognizer 
            {
               for (id ann in mapView.selectedAnnotations) 
               {
                   [mapView deselectAnnotation:ann animated:NO];
               }      
    
    
            }   
    

提交回复
热议问题