【问题标题】:startMonitoringForRegion in iPhone SimulatoriPhone 模拟器中的 startMonitoringForRegion
【发布时间】:2012-01-24 08:03:05
【问题描述】:

我正在模拟器上测试区域监控。 [CLLocationManager regionMonitoringAvailable] 和 [CLLocationManager regionMonitoringEnabled] 都返回 YES。 我在 plist 中添加了用于位置更新的应用程序寄存器。 我在 AppDelegate 中有一个全局位置管理器,并且 startUpdatingLocation 在前台和后台都可以正常工作。

那我有

CLLocationCoordinate2D p = CLLocationCoordinate2DMake(45.488, 9.16);
CLRegion *region=[[CLRegion alloc] initCircularRegionWithCenter:p radius:100.0 identifier:@"emanuele"];
CLLocationAccuracy acc=200.0;
[locationManager startMonitoringForRegion:region desiredAccuracy:acc];

但是在模拟器上进行测试时,我既无法获得 didEnterRegion 也无法获得 monitoringDidFailForRegion。 我做错了什么或遗漏了什么?

非常感谢。

【问题讨论】:

    标签: ios ios5 cllocationmanager


    【解决方案1】:

    您的半径似乎只有 100 米,但您的精度设置为 200 米。尝试将准确度设置为最佳,看看是否有改进的结果。

    您的坐标看起来也不够准确,无法下到 100 米。尝试更精确的坐标,精度更高。其他一切看起来都很好。

    【讨论】:

    • 你好@Bill,我有点困惑。你说significantLocationUpdate 不能用于模拟器,因为它使用了手机信号塔切换(stackoverflow.com/questions/8541973/…)。所以,我希望在这里也能得到类似的区域监控答案,但是......!?区域监控应该在模拟器上工作吗? (我另有观察......)
    • 如果设置正确,我已经能够在模拟器中很好地测试区域监控。我在 Debug-->Location 中使用自定义位置。我只是还没有看到测试模拟器中重大变化的好方法。希望这会有所帮助。
    • 我明白了。在我的代码中,didEnterRegion 似乎会触发,但didExitRegion 不会。不过,当我有时间时,我会三次检查我的代码。感谢您的信息!
    【解决方案2】:

    我认为模拟器中的区域监控已损坏。我的应用程序(GeoControl)中的区域监控在设备上运行但在模拟器上运行时运行良好。具体来说,当我使用 Debug>Location>FreewayDrive 时,模拟器中不会调用 didEnterRegion 和 didExitRegion。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-01
      • 2010-12-09
      • 2012-05-04
      • 1970-01-01
      • 2011-04-08
      • 2010-11-15
      • 1970-01-01
      相关资源
      最近更新 更多