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