当我启动我的应用程序时,它将显示带有用户位置的mapView,但是mapView不会立即显示UserLocation,打印一些错误,大约3分钟后,它将调用“didUpdateUserLocation”,然后显示用户的位置。它大约成功定位了几分钟,但在定位成功之前总是失败。

我的代码在iOS7中工作正常,但在iOS9中有此问题,我不知道为什么。

我将self.locationManger.startUpdatingLocation()称为viewDidLoad()

这是我的mapView

 lazy var mapView: MKMapView = {
    var tempMapView = MKMapView(frame: self.view.bounds)
    tempMapView.mapType = MKMapType.Standard
    tempMapView.showsUserLocation = true
    tempMapView.userTrackingMode = MKUserTrackingMode.Follow
    tempMapView.delegate = self
    return tempMapView
    }()

这是打印错误
/BuildRoot/Library/Caches/com.apple.xbs/Sources/ProtocolBuffer/ProtocolBuffer-242/Runtime/PBRequester.m:807 server (https://gsp13-cn.ls.apple.com/localshift) returned error: 504
/BuildRoot/Library/Caches/com.apple.xbs/Sources/ProtocolBuffer/ProtocolBuffer-242/Runtime/PBRequester.m:807 server (https://gsp13-cn.ls.apple.com/localshift) returned error: 503

最佳答案

致电Startupdate位置:

manager = CLLocationManager()
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.startUpdatingLocation()

另外检查一下:http://nshipster.com/core-location-in-ios-8/

10-06 02:34