didRangeBeacons
方法在 iOS 9 中几乎每秒 40 次。然而,在 iOS 8 及更低版本中,它每秒仅被调用一次。因此,我们在 didRangeBeacons
中的代码逻辑未按预期工作。
重现步骤:
- 向您的任何 ViewController 或 AppDelegate 添加 CLLocationManager 委托(delegate)。
- 初始化位置管理器。
开始测距 -
[self.locationManager startRangingBeaconsInRegion:savedRegion];
看看 didRangeBeacons 被调用的频率。
Expected Results: Should get called once every second.
Actual Results: Is getting called more than 40 times every second
版本: iOS 9 及更高版本
最佳答案
确保您没有更改 didRangeBeacons 方法中的任何 CLLocationManager 属性。这将导致 CLLocationManager 再次调用 didRangeBeacons,您将在一秒钟内完成大量更新。
我在“startUpdatingLocation”中遇到过这种情况,但应该有结果。
关于iOS 9 didRangeBeacons 调用了更多次。 iOS-8 每秒一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32942945/