【问题标题】:CLGeocoder reverseGeocodeLocation not working for simulated locationCLGeocoder reverseGeocodeLocation 不适用于模拟位置
【发布时间】:2018-01-31 13:18:55
【问题描述】:

我通过 XCode 检查方案启用了位置模拟 Allow Location Simulation 并从下拉列表中选择示例位置 - New York, NY, USA

这是我从位置获取地点信息的代码。 currentLocation 来自CLLocationManager,我看到该值与NewYork 位置完全相同。

- (void) fetchPlacemarks: (CLLocation*) currentLocation
{
  // Reverse-geolocate the current location
  CLGeocoder* geoCoder = [[CLGeocoder alloc] init];
  [geoCoder reverseGeocodeLocation: currentLocation
                 completionHandler: ^(NSArray<CLPlacemark*>* placemarks,
                                      NSError*               error)
   {
      // getting error "The operation couldn’t be completed. (kCLErrorDomain error 8.)"
   }
}

我已经通过模拟器和具有真实位置(不是模拟)的设备进行了测试,但它们的工作原理就像一个魅力。 只有它在模拟位置的设备中不起作用。 这里有什么问题?

【问题讨论】:

    标签: ios objective-c xcode location clgeocoder


    【解决方案1】:

    在真机上,只能通过调试器进行模拟,看这里enter link description here

    【讨论】:

    • 是的。我以调试模式运行应用程序。我得到的当前位置与模拟位置(纽约)完全相同。
    • 通过编辑模式设置默认位置(产品->模式->编辑模式->运行(左面板)->选项(选项卡)->选中“允许位置模拟器”)=>选择位置从下拉 => 在设备上调试测试项目 => 断开数据线,然后开始测试您想要的应用程序
    • 不,这不是答案。
    猜你喜欢
    • 1970-01-01
    • 2012-12-03
    • 2016-12-05
    • 2012-03-20
    • 2013-02-10
    • 2014-08-21
    • 1970-01-01
    • 2017-01-05
    • 2020-02-03
    相关资源
    最近更新 更多