1
我使用Estimotes室内位置构建应用程序,任何我使用CoreLocation来查找我们的信标,并且我的应用程序将更改label.text。应用程序可以运行,但没有工作,label.text不能更改。CoreLocation不能使用Estimotes Beacon
override func viewDidLoad() {
super.viewDidLoad()
let path = NSBundle.mainBundle().pathForResource("location", ofType: "json")
do {
let content = try String(contentsOfFile: path!, encoding: NSUTF8StringEncoding)
let locationSetup = ESTLocationBuilder.parseFromJSON(content)
//set up delegate
manager.delegate = self
locationManager.delegate = self
if (CLLocationManager.authorizationStatus() != CLAuthorizationStatus.AuthorizedWhenInUse) {
locationManager.requestWhenInUseAuthorization()
}
locationManager.startRangingBeaconsInRegion(region)
}
func locationManager(manager: CLLocationManager, didRangeBeacons beacons:[CLBeacon], inRegion region: CLBeaconRegion){
let knownBeacons = beacons.filter{ $0.proximity != CLProximity.Unknown }
if (knownBeacons.count > 0){
let closestBeacon = knownBeacons[0] as CLBeacon
if(closestBeacon.minor.integerValue == 41016)
{
self.snow.text = "find"
}
}
}
尝试在didRangeBeacons中添加NSLog语句:inRegion:并在两个if语句中。哪些日志行被打印? – davidgyoung
如果(knownBeacons.count> 0){NSLog(“find beacon”)和if(closestBeacon.minor.integerValue == 41016){NSLog(“catch”)}添加NSLog代码,但输出无法打印任何东西,我不知道为什么这个功能无法运行。 –
在代码中你初始化'locationManager'?我没看到。可能是零吗? – davidgyoung