After setting mapView.showsUserLocation
to true, is it possible to receive location updates without showing the MKUserLocation bubble? Returning nil in mapView:viewForAnnotation:
simply shows the bubble, and returning any other kind of annotation shows an annotation, which I don't want.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can hide the user location's view in the didAddAnnotationViews
delegate method:
-(void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *ulv = [mapView viewForAnnotation:mapView.userLocation];
ulv.hidden = YES;
}
回答2:
Swift 3:
func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
if let userLocation = mapView.view(for: mapView.userLocation) {
userLocation.isHidden = true
}
}