【发布时间】:2018-10-04 13:12:31
【问题描述】:
我正在尝试在 iOS 10 中使用 Swift 4 构建 iBeacons 应用。许多来源推荐以下内容:
func locationManager(_ manager: CLLocationManager, didStartMonitoringFor region: CLRegion) {
manager.requestState(for: region)
}
处理应用在信标区域内启动的情况。但是,这种方法在某些情况下似乎会导致副作用和时间错误。
现在,我发现这篇 StackOverflow 文章 Understanding iBeacons in iOS 指出,“didDetermineState 仅在您开始监控时自动调用”。
果然,如果我不打电话给requestState(for: region),只打电话给locationManager.startMonitoring(for: region),一切都会完美!
谁能证实确实如此?如果我打电话给startMonitoring,那么就不需要requestState了吗?
注意:我在开始监控之前将notifyEntryStateOnDisplay 设置为true。我想知道这是否与它有关。
【问题讨论】:
标签: ios swift core-location ibeacon