0
我有一个问题,我无法在任何地方找到答案,我在viewController中有一个全局CLLocationManager()变量,以便我可以看到当用户使用locationManager的callBacks进入或离开某个位置时,它一次只能在一个位置完美运行,但我想让应用程序同时监视2个或更多的位置。 我创建了一个函数来启动它:CLLocationManager是否可以在swift中同时管理2个或多个位置3
var coreLocationManger = CLLocationManager()
func setMonitoredRegion(location:CLLocation) {
let startLocation = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
let monitoredRegion = CLCircularRegion(center: startLocation, radius: 100, identifier: "Local Region")
coreLocationManger.startMonitoring(for: monitoredRegion)
coreLocationManger.allowsBackgroundLocationUpdates = true
coreLocationManger.delegate = self
monitoredRegion.notifyOnEntry = true
monitoredRegion.notifyOnExit = true
}
本功能,要求提供一个位置来管理,当我这个多次与不同的地点使用,它只是管理着被赋予了最后一个位置! 你们有任何提示吗? 谢谢
这将是有道理的,我即将尝试它,并回来一些反馈谢谢! :) – mastercoder
它工作非常感谢:) – mastercoder
我很高兴它帮助。你介意将答案标记为正确答案吗? –