0

MKMapView delegate methods not called in iOS 8. In viewDidLoad:

CGRect mapViewFrame = CGRectMake(0.0, 129.0, 320.0, 419.0);
    _mapView = [[MKMapView alloc] initWithFrame:mapViewFrame];
    [_mapView setMapType:MKMapTypeStandard];
    [_mapView setDelegate:self];
    [_mapView setShowsUserLocation:YES];

These methods are never called:

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{};

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {}

In previous versions of iOS 8 everything worked.

Joker
  • 167
  • 1
  • 3
  • 12

2 Answers2

0

I think user location retrieval has changed in iOS 8. Now you need to use CLLocationManager authorisation to track user location. mapView.showsUserLocation = YES is not enough anymore.

You need a CLLocationManager instance:

@property(nonatomic, strong) CLLocationManager *locationManager;

In viewDidLoad

self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
    [self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
// your mapKit stuff...

And this should start tracking user's location and call the delegate methods.

Danny S
  • 1,291
  • 8
  • 12
0

Have you tried adding other annotations (not user location) and seeing if the delegate methods get called? That will help you troubleshoot the problem

royherma
  • 4,095
  • 1
  • 31
  • 42