如何通过GPS获取我当前所在的城市或街道

来源:互联网 发布:2016年癌症数据 编辑:程序博客网 时间:2024/05/01 07:29

如何通过GPS获取我当前所在的城市或街道


http://www.cocoachina.com/bbs/read.php?tid=54370&page=1


  1. - (void)startedReverseGeoderWithLatitude:(double)latitude longitude:(double)longitude{
  2.     CLLocationCoordinate2D coordinate2D;
  3.     coordinate2D.longitude = longitude;
  4.     coordinate2D.latitude = latitude;
  5.     MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:coordinate2D];
  6.     geoCoder.delegate = self;
  7.     [geoCoder start];
  8. }#pragma mark -
  9. - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
  10. {
  11. //NSString *subthroung=placemark.subThoroughfare;
  12. NSString *local=placemark.locality;
  13. //NSLog(@"城市名:%@-%@-%@",placemark.locality,local,subthroung);
  14.     if (local) {
  15.         [cityLabel setText:local];
  16.     }
  17. }
  18. - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
  19. {
  20. }

原创粉丝点击