-2

Code:

map.UserTrackingMode = MKUserTrackingMode.FollowWithHeading;

But after a user interacts with the map or after mKMapView.ShowAnnotations, the map automatically stops following the device's heading. (Not by my code. That's just how mkmapview works. This is also the case in the built in Maps app.)

How can I make the map start following the device's heading again from code?

4

1 回答 1

1

This is exactly like how the Maps app works and is what the user will expect. The behavior you're describing is completely normal; you shouldn't interfere with it.

The usual thing is that you put an MKUserTrackingButton in the interface, associated with the map view, and the user can just tap it to switch modes automatically. Except for initially configuring the button, no code is needed.

https://developer.apple.com/documentation/mapkit/mkusertrackingbutton

or

https://developer.apple.com/documentation/mapkit/mkusertrackingbarbuttonitem

于 2019-11-18T21:47:32.950 回答