0
我一直在使用大量的教程,並且每個教程都持續有完全相同的問題。當我運行下面的代碼或其他教程吧其他的化身,我不斷收到:用Swift在CoreLocation中搜索區域的正確方法是什麼?
2015-06-12 13:50:33.797 Scanner[4599:2593734] *** Assertion failure in -[CLLocationManager startRangingBeaconsInRegion:], /SourceCache/CoreLocationFramework/CoreLocation-1756.0.20/Framework/CoreLocation/CLLocationManager.m:1129
2015-06-12 13:50:33.798 Scanner[4599:2593734] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: region != nil'
*** First throw call stack:
(0x183efc2d8 0x1957200e4 0x183efc198 0x184db0ed4 0x18464f0d4 0x10008bebc 0x10008bf60 0x18893cc84 0x18893c994 0x1889431d0 0x188940880 0x1889b28ec 0x188bc6a94 0x188bc9208 0x188bc7778 0x18c7053c8 0x183eb427c 0x183eb3384 0x183eb19a8 0x183ddd2d4 0x1889a843c 0x1889a2fac 0x1000923b4 0x195d9ea08)
libc++abi.dylib: terminating with uncaught exception of type NSException
我切換(地區)(區域!),並得到一個輸出說,雖然展開意想不到的零發生錯誤。
我非常惱火,並嘗試了一些可能性。有誰知道問題是什麼?它在屏幕加載時崩潰。
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
let locationManager = CLLocationManager()
let region = CLBeaconRegion(proximityUUID: NSUUID(UUIDString: "1800"), identifier: "BLE113")
override func viewDidLoad(){
super.viewDidLoad()
locationManager.delegate = self;
if (CLLocationManager.authorizationStatus() != CLAuthorizationStatus.AuthorizedWhenInUse) {
locationManager.requestWhenInUseAuthorization()
}
locationManager.startRangingBeaconsInRegion(region)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func locationManager(manager: CLLocationManager!, didRangeBeacons beacons: [AnyObject]!, inRegion region: CLBeaconRegion!) {
println(beacons)
}
}
我遇到了您的func locationManager版本問題。它給了我:/Users/markhardy/Desktop/Development/Scanner/Scanner/ViewController.swift:68:10:Objective-C方法'locationManager:didRangeBeacons:inRegion:'由方法提供'locationManager(_:didRangeBeacons:inRegion :) '與協議'CLLocationManagerDelegate'中的可選需求方法'locationManager(_:didRangeBeacons:inRegion :)'衝突'但是我可以通過用Anyobject替換CLBeacon來構建它' – user3246092
它正在構建中,但它似乎並沒有起作用我的設備很不幸 – user3246092
你可以打破並跟蹤2「如果讓」。你在使用什麼UUIDString? – Laurent