在模拟器中更新位置但不在设备中更新

location updating in simulator but not in device

我正在尝试通过使用核心位置来获取用户的更新位置 framework.It 在模拟器中工作,但在 ipad/iphone 中不工作。我正在使用以下代码来获取它。在模拟器中,我正在使用高速公路。

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

 CLLocation *currentLocation=newLocation;
 NSLog(@"location : %@",currentLocation);

if(currentLocation !=nil)
{
 self.latitudelabel.text = [NSString 
 stringWithFormat:@"%.8f",currentLocation.coordinate.latitude];
 self.longitudelabel.text = [NSString  
 stringWithFormat:@"%.8f",currentLocation.coordinate.longitude];
}

CLLocationDistance distance = [newLocation distanceFromLocation:oldLocation];

NSLog(@"Calc.distance%f",distance);

[geocoder reverseGeocodeLocation:currentLocation completionHandler:^
(NSArray   *placemarks, NSError *error)
{

 if(error == nil && [placemarks count]>0)
 {
     placemark = [placemarks lastObject];
     NSLog(@"Country %@",placemark.country);
     NSLog(@"Area %@",placemark.administrativeArea);
     NSLog(@"City %@",placemark.locality);
     NSLog(@"Code %@",placemark.postalCode);
     NSLog(@"Road %@",placemark.thoroughfare);
     NSLog(@"Number %@",placemark.subThoroughfare);

     self.addresslabel.text = [NSString stringWithFormat:@"%@ %@ 
\n %@ %@    \n %@ \n %@",
 placemark.subThoroughfare,    placemark.thoroughfare,
                          placemark.postalCode, placemark.locality,
                          placemark.administrativeArea,
                          placemark.country];

 }
 else
 {
     NSLog(@"tktk%@",error.debugDescription);

 }
}];

}

进去settings > Privacy > Location services > Your app > Always.

您还可以查看以下问题中发布的其他替代方案 Core Location not working in iOS 8