No zoom/etc. with mapView:didUpdateUserLocation:


#1

Hi,

I’m working through chapter 5 and after the documentation section where we implemented the following method:

  • (void)mapView:(MKMapView *)mapView
    didUpdateUserLocation:(MKUserLocation *)userLocation
    {
    CLLocationCoordinate2D loc = [userLocation coordinate];
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 250, 250);
    [worldView setRegion:region animated:YES];
    }

I build and run the application, which brings up the 5.1 sim and I see the map, change the location with the debugger, but the sim doesn’t change the view at all. No zoom, no animation… the indicator just moves to wherever I specified with the debugger. HALP


#2
  1. Put an NSLog in that method to ensure that it is called.
  2. Ensure that worldView is actually pointing at the worldView created from the XIB file.

You can kill two birds with one stone by doing the following at the beginning of this method:

NSLog(@"%@", worldView);

If you don’t see it, then that means the delegate of the worldVIew isn’t set to be the WhereamiViewController - control-drag from the MKMapView in the XIB to the File’s Owner and select delegate.

If you do see it, and it prints (null), control-drag from the File’s Owner to the MKMapView in the XIB and select worldView.


#3

Or in my case, I was implementing a method called “mapview” instead of “mapView” which caused it to miss silently.


#4

[quote=“JoeConway”]1. Put an NSLog in that method to ensure that it is called.
2. Ensure that worldView is actually pointing at the worldView created from the XIB file.

You can kill two birds with one stone by doing the following at the beginning of this method:

NSLog(@"%@", worldView);

If you don’t see it, then that means the delegate of the worldVIew isn’t set to be the WhereamiViewController - control-drag from the MKMapView in the XIB to the File’s Owner and select delegate.

If you do see it, and it prints (null), control-drag from the File’s Owner to the MKMapView in the XIB and select worldView.[/quote]

Hello Joe,
if you could help me, that would be appreciate.
I tried as you say and all connections are made and configured as you suggest.
The problem is that none change of location occurred. I made a few attempts but nothing.
I digit the new location in the text field but location is not being updated at all…

I had ran your code that come along the zip but it is always the same.
The code doesn’t do what it is supposed to do.

Any suggestion?
Thank you!