MKMapView's user location is wrong on startup or resume

前端 未结 7 1985
臣服心动
臣服心动 2021-01-17 19:15

When I start my application fresh, or resume after a long time, MKMapView\'s notion of the userLocation is wrong and shows me in the middle of the sea.

I am using th

7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-17 19:50

    This is unfortunately a function of the GPS chip. It's not always on, so the data will usually be wrong for the first couple of moments. Your best bet would probably be to store the last position recorded by the app in NSUserDefaults, then wait for the precision to be where you want it to be before switching to live data, or else hide the MkMapView until the precision is where you want it to be, then display it at that point (you could show a loading screen in the interim)

提交回复
热议问题