ios - startMonitoringForRegion is not sending to didEnterRegion or didExitRegion -
i have location based app, though region correct app never moves didenterregion or didexitregion
for (int x = 0; x <= [[[taskstore sharedstore] alltasks]count]-1; x++) { nsarray *tasks = [[taskstore sharedstore] alltasks]; task *selectedtask = [tasks objectatindex:x]; location.latitude = selectedtask.locationcoord.coordinate.latitude; location.longitude = selectedtask.locationcoord.coordinate.longitude; nsstring* desiriedloc = [selectedtask locationname]; clregion *region = [[clregion alloc] initcircularregionwithcenter: location radius: 30.0 identifier: desiriedloc]; nslog(@"entered new location in region %@", region); [locmanager startmonitoringforregion:region]; } -(void)locationmanager:(cllocationmanager *)manager didenterregion:(clregion *)region { nslog(@"didenterregion %@",region.identifier); uialertview *alr=[[uialertview alloc] initwithtitle:@"reminder didenterregion" message:region.identifier delegate:nil cancelbuttontitle:nil otherbuttontitles:@"ok",nil]; [alr show]; } -(void)locationmanager:(cllocationmanager *)manager didexitregion:(clregion *)region { nslog(@"didexitregion %@",region.identifier); uialertview *alr=[[uialertview alloc] initwithtitle:@"reminder didexitregion" message:region.identifier delegate:nil cancelbuttontitle:nil otherbuttontitles:@"ok",nil]; [alr show]; } here string print out location:
entered new location coordinates latitude: 51.509980 longitude: -0.133700
and here string print out region:
entered new location in region (identifier london) <+51.50998000,-0.13370000> radius 30.00m
as @verbumdei commented, way -didenterregion , -didexitregion establish cllocationmanagerdelegate. set view delegate , add methods , should see update.
one thing note, using 30m radius, need quite approximate in location if want trigger updates. easy in simulator, in real life usage (on device), 30m accuracy bit tougher. start 100m , work way down based on experience.
Comments
Post a Comment