I tried to set the user tracking mode in the viewDidLoad method (and in viewWillAppear). If I set it to MKUserTrackingModeFollowWithHeading (value of 2), it does not take effect. Actually, right after setting its value to 2, if I print it value, it is 1, why? I have never seen such a thing in any programming experience!
Here is how I set it:
[self.mapView setUserTrackingMode: MKUserTrackingModeFollowWithHeading
animated: YES];
If I do the same in the viewWillAppear method, the effect is the same. However, the second time this view is displayed, the setting will take effect. (I have a tab viewcontroller, I switch the view to another and then switch back).
The way I see it does not take effect is two measures: (1) print its value right after setting it (2) in the map view, the heading is not displayed.
What the is going on?
I know this is a really old post, but just in case it helps others out there looking for a solution, the reason is because you need to set the userTrackingMode after the map has loaded. So set your class as the delegate, then add this delegate method:
- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView {
mapView.userTrackingMode = MKUserTrackingModeFollowWithHeading;
}
I also have the same issue. Cannot find any information in the map header about it not working, or working for that matter.
The solution I've implemented is to use a custom CLLocationManager to retrieve the heading, and then rotate the map appropriately. See this answer for some help using this method: Rotate MapView using Compass orientation
Also note that the iOS simulator doesn't currently allow for heading simulation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With