Note that there are some explanatory texts on larger screens.

plurals
  1. POMKMapView didUpdateUserLocation not being called
    text
    copied!<p>I am following the big nerd ranch guide book and have modified my app delegate.h to look like this:</p> <pre><code> #import &lt;UIKit/UIKit.h&gt; #import &lt;CoreLocation/CoreLocation.h&gt; #import &lt;MapKit/MapKit.h&gt; @interface WhereamiAppDelegate : NSObject &lt;UIApplicationDelegate,CLLocationManagerDelegate, MKMapViewDelegate&gt; { IBOutlet UITextField *locationTitleField; IBOutlet UIActivityIndicatorView *activityIndicator; IBOutlet MKMapView *worldView; CLLocationManager *locationManager; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext; @property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel; @property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator; - (void)saveContext; - (NSURL *)applicationDocumentsDirectory; @end </code></pre> <p>The .m looks like this:</p> <pre><code> #import "WhereamiAppDelegate.h" @implementation WhereamiAppDelegate @synthesize window = _window; @synthesize managedObjectContext = __managedObjectContext; @synthesize managedObjectModel = __managedObjectModel; @synthesize persistentStoreCoordinator = __persistentStoreCoordinator; -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation { CLLocationCoordinate2D loc = [userLocation coordinate]; MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 250, 250); [worldView setRegion:region animated:YES]; NSLog(@"didUpdateUserLocation is called"); } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. // Create location manager object locationManager = [[CLLocationManager alloc] init]; // There will be a warning from this line of code; ignore it for now [locationManager setDelegate:self]; // We want all results from the location manager [locationManager setDistanceFilter:kCLDistanceFilterNone]; // And we want it to be as accurate as possible // regardless of how much time/power it takes [locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; // Tell our manager to start looking for its location immediately // [locationManager startUpdatingLocation]; [worldView setShowsUserLocation:YES]; // This line may say self.window, don't worry about that [self.window makeKeyAndVisible]; return YES; } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@"%@", newLocation); } - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { NSLog(@"Could not find location: %@", error); } </code></pre> <p>When I open the app it should ZOOM into my location. But it doesn't zoom, so i put an NSLog in the didUpdateUserLocation to see if it was called. But it was never printed, so it wasn't called. How do I fix this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload