didUpdateLocation Method Never Called

后端 未结 6 950
南旧
南旧 2021-01-05 10:40

I am making one app on iphone sdk4.0.In that did update location method never called. I have given my code below.Please help.Thanks in advance.

-(id)init
{
          


        
6条回答
  •  一个人的身影
    2021-01-05 11:08

    HI, your codes seems ok. now these can be possible reasons :

    on your init: try to check if there is locationServicesEnabled or not.

    locationManager = [[CLLocationManager alloc] init];
    if(locationManager.locationServicesEnabled == NO){
        //Your location service is not enabled, Settings>Location Services  
    }
    

    other reason, you may disallow to get location to your app. solution: simply remove your application from iPhone and re-build, now it should popup dialog to Allow location.

    use this to check error

    - (void)locationManager:(CLLocationManager *)manager
           didFailWithError:(NSError *)error
    {       
        NSLog(@"Error while getting core location : %@",[error localizedFailureReason]);
        if ([error code] == kCLErrorDenied) {
            //you had denied 
        }
        [manager stopUpdatingLocation];
    }
    

    otherwise all seems ok, you were already running ios 4.0 , which can be install in iPhone 3G and later, if it was iPhone 2g, then this problem may occur.

提交回复
热议问题