Map View always center map on my location

后端 未结 3 537
误落风尘
误落风尘 2021-01-07 04:52

I use the following code to get my location when a user presses a button

 [mapview setShowsUserLocation:YES];

and then the follwoing to cen

3条回答
  •  长情又很酷
    2021-01-07 05:26

    I think it came in with iOS5, you can now drop the delegate stuff and just set the userTrackingMode of the MKMapView. Set it to MKUserTrackingModeFollow to make the make move along with the user and then when they start panning the map around it'll turn off the tracking mode automatically, you then just need to provide a button to turn it back on.

提交回复
热议问题