【问题标题】:CLBeaconRegion not monitored with StartMonitoringForRegion in simulator with XCTest使用 XCTest 在模拟器中使用 StartMonitoringForRegion 未监控 CLBeaconRegion
【发布时间】:2016-03-15 22:14:39
【问题描述】:

在我的 XCTest 案例中,我使用我的 CLLocationManager 实例在 CLBeaconRegion 上调用 StartMonitoringForRegion,但它没有出现在我的受监控区域属性中。它只发生在模拟器中。是错误还是我做错了什么?

【问题讨论】:

    标签: ios objective-c cllocationmanager xctest clbeaconregion


    【解决方案1】:

    模拟器无法监控信标,所以这总是会失败。如果您想使用信标测试区域监控,您需要使用设备。 这与 XCText 没有任何关系,只是模拟器无法监控信标。我相信您仍然可以监视区域,因为模拟器和模拟位置,它只是无法模拟检测信标。

    【讨论】:

    • 我添加了 monitoringDidFailForRegion 方法,但它根本没有被调用。似乎 startMonitoringForRegion 根本不起作用。奇怪的是,如果我添加 CLCircularRegion 而不是 CLBeaconRegion,它会起作用,它会显示在我的受监控区域属性中。这正常吗?
    • 抱歉不正确。我更新了我的答案。 MonitoringDidFail 仅在您尝试监控超过 20 个区域时调用。我的错误,但真正的原因是因为您无法使用模拟器监控信标
    猜你喜欢
    • 1970-01-01
    • 2012-01-24
    • 1970-01-01
    • 1970-01-01
    • 2013-10-08
    • 1970-01-01
    • 2015-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多