didUpdateToLocation doesn't gets called immediately

℡╲_俬逩灬. 提交于 2019-12-07 09:13:33

Maybe you should consider using startUpdatingLocation method instead of startMonitoringSignificantLocationChanges. From iOS docs:

startUpdatingLocation

This method returns immediately. Calling this method causes the location manager to obtain an initial location fix (which may take several seconds) and notify your delegate by calling its locationManager:didUpdateToLocation:fromLocation: method.

It can take several seconds to several minutes to get a good location depending on whether you have cell or wifi connection, and whether you have good signals from the GPS satellites. However, you should get a cached (possibly outdated) location right away.

Did you set the delegate for your locationMangerObject?

Did your function return to the runloop after calling the startMonitoringSignificantLocationChanges?

///Hmmmmm

            ...CLLocationManager does n't call delegate method properly 
            ...after lot of R&D I'm  using a watchdog method it calls " -(void)locationadd " function every 10seconds and i'm using that location for drawing the path.

  -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
     {
     }       



 - (void)viewDidLoad
     {

   [NSTimer scheduledTimerWithTimeInterval:10
                                         target:self
                                           selector:@selector(locationadd)
                                           userInfo:nil
                                           repeats:YES];

        }


        -(void)locationadd   
        {

         if ([locationManager location]) {



        //i'm saving this location

    CLLocation *locat=locationManager.location;

     }

        }
        //
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!