当我启动我的应用程序时,它会显示一个带有用户位置的 mapView,但 mapView 不会立即显示 UserLocation,打印一些错误,大约 3 分钟后,它会调用“didUpdateUserLocation”,然后显示用户的位置。大概几分钟定位成功,之前定位一直失败。
我的代码在 iOS7 中运行良好,但在 iOS9 中出现此问题,我不知道为什么。
我在 viewDidLoad()
中调用了 self.locationManger.startUpdatingLocation()
。
这是我的 map View
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
最佳答案
调用启动更新位置:
manager = CLLocationManager()
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.startUpdatingLocation()
关于ios - 为什么 mapView 不立即显示用户位置,打印一些错误,大约 3 分钟后,它调用 'didUpdateUserLocation',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33992992/