- (void)locationManager:(CLLocationManager *)manager 
    didUpdateToLocation:(CLLocation *)newLocation 
           fromLocation:(CLLocation *)oldLocation {
//获取所在地城市名
    CLGeocoder *geocoder=[[CLGeocoder alloc]init];
    [geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks,NSError *error)
     {
         for(CLPlacemark *placemark in placemarks)
         {
             self.currentCity=[[placemark.addressDictionary objectForKey:@"City"] substringToIndex:2];
             NSLog(@"str%@",currentCity);
         }
     }];
    [self.locationManager stopUpdatingLocation];
}

相关文章:

  • 2021-08-19
  • 2021-10-31
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2021-10-06
猜你喜欢
  • 2021-10-01
  • 2022-01-15
  • 2021-09-02
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案