Note that there are some explanatory texts on larger screens.

plurals
  1. POCLLocation Manager didStartMonitoringForRegion delegate method not called
    text
    copied!<p>I am trying to use location monitoring in my app. I can set my location and reverseGeocode the location I want to monitor. the <code>didUpdateToLocation</code> delegate method works fine, and updates continuously but the <code>didStartMonitoingForRegion</code> delegate never gets called, nor do the <code>didExitRegion</code> nor <code>didEnterRegion</code>.</p> <p>Any suggestions?</p> <pre><code>- (IBAction)setLocation:(UIButton *)sender { if(!self.locationManager) self.locationManager = [[CLLocationManager alloc] init]; [self.locationManager setDelegate:self]; [self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [self.locationManager setDistanceFilter:10]; // Update again when a user moves distance in meters [self.locationManager setPurpose:@"Set location based alerts if switch is on"]; self.plugLocation=nil; //reset to nil so didUpdateToLocation will update it self.distanceLabel.text=[NSString stringWithFormat:@"%d",0]; [self.locationManager startUpdatingLocation]; if ( ![CLLocationManager regionMonitoringAvailable] || ![CLLocationManager regionMonitoringEnabled] ){ NSLog(@"Location monitoring not Unavailable"); }else { } } -(void)setPlugLocation:(CLLocation *)plugLocation{ // if (!_plugLocation) _plugLocation=[[CLLocation alloc]init]; _plugLocation=plugLocation; if (_plugLocation) { [self setRegion:plugLocation radius:20 name:self.plugName]; [self reverseGeocode:self.plugLocation]; NSLog(@"setPlugLocation %@", [self.plugLocation description]); } } -(void)setRegion:(CLLocation *)center radius:(double)meters name:(NSString*)name{ CLLocationCoordinate2D plug2D; plug2D.latitude=center.coordinate.latitude; plug2D.longitude=center.coordinate.longitude; CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:plug2D radius:meters identifier:name]; [self.locationManager startMonitoringForRegion:region desiredAccuracy:kCLLocationAccuracyBest]; } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{ self.latitudeLabel.text=[NSString stringWithFormat:@"%f",newLocation.coordinate.latitude]; self.longitudeLabel.text=[NSString stringWithFormat:@"%f",newLocation.coordinate.longitude]; if (self.plugLocation == nil)self.plugLocation = newLocation; if (self.plugLocation!=nil) { CLLocationDistance distanceBetween = [newLocation distanceFromLocation:self.plugLocation]; NSLog(@"didUpdateToLocation Distance from plug=%f",distanceBetween); self.distanceLabel.text=[NSString stringWithFormat:@"%f",distanceBetween]; } } -(void)reverseGeocode:(CLLocation *)coordinates;{ if (!self.plugGeo) self.plugGeo = [[CLGeocoder alloc] init]; [self.plugGeo reverseGeocodeLocation:coordinates completionHandler:^(NSArray *placemarks, NSError *error) { if (error==nil&amp;&amp;[placemarks count]&gt;0) { CLPlacemark *placemark=[placemarks objectAtIndex:0]; NSLog(@" setPlugLocation geocodeAddressString %@",placemark); //should also transfer back to plug detail and save self.locationLabel.text=[NSString stringWithFormat:@"%@ %@\n%@, %@", placemark.subThoroughfare, placemark.thoroughfare, placemark.locality,placemark.postalCode]; [self sendAlertMessage:[NSString stringWithFormat:@"%@ %@\n%@, %@", placemark.subThoroughfare, placemark.thoroughfare, placemark.locality,placemark.postalCode] title:@"Success"]; }else { NSLog(@" setPlugLocation couldn't geoCode address %@",error); } }]; } </code></pre>
 

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