Hide MKUserLocation when MKMapView showsUserLocation == YES

前端 未结 2 452
离开以前
离开以前 2021-01-03 00:04

After setting mapView.showsUserLocation to true, is it possible to receive location updates without showing the MKUserLocation bubble? Returning nil in ma

相关标签:
2条回答
  • 2021-01-03 00:58

    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;
    }
    
    0 讨论(0)
  • 2021-01-03 01:08

    Swift 3:

    func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
       if let userLocation = mapView.view(for: mapView.userLocation) {
            userLocation.isHidden = true
       }
    }
    
    0 讨论(0)
提交回复
热议问题