How to stop the viewForAnnotation method from overriding the default user location blue beacon in iOS

前端 未结 2 581
说谎
说谎 2020-12-15 06:30

Right now I am populating a map view with annotations, and also displaying the user\'s current location. With the viewForAnnotation method, it overrides all annotations with

2条回答
  •  萌比男神i
    2020-12-15 07:10

    Check out the documentation here:

    http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapViewDelegate_Protocol/MKMapViewDelegate/MKMapViewDelegate.html

    As it states:

    If the object in the annotation parameter is an instance of the MKUserLocation class, you can provide a custom view to denote the user’s location. To display the user’s location using the default system view, return nil.

    So you can add a conditional to check for this:

    if([annotation isKindOfClass: [MKUserLocation class]]) {
      return nil;
    }
    

提交回复
热议问题