ios - 为什么 mapView 不立即显示用户位置,打印一些错误,大约 3 分钟后,它调用 'didUpdateUserLocation'

标签 ios swift location mkmapview ios9

当我启动我的应用程序时,它会显示一个带有用户位置的 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()

同时检查这个:http://nshipster.com/core-location-in-ios-8/

关于ios - 为什么 mapView 不立即显示用户位置,打印一些错误,大约 3 分钟后,它调用 'didUpdateUserLocation',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33992992/

相关文章:

ios - 如何更新uitableviewcell中的约束动画

ios - 如何获取iOS视频嵌入的分析(og:video)

ios - 消除项目中的错误

ios - 即使应用程序被终止,在 iOS 中实现定期位置更新

java - 在 googleMap (android) 中更新位置

ios - 如何在 iOS 版 MonoTouch/Xamarin 中导航命名空间?

objective-c - 切换 View 后 UIText 字段不响应触摸

ios - Swift - MKAnnotationView map 图钉的自定义 UIView

java - 如果用户在设备上选择了省电定位模式,是否可以在 Android 上获得高精度位置更新?

swift - GeoFire + Swift+ Firebase : Save current location