0

I want to run a function at the end of animation of the function setUserTrackingMode: https://docs.mapbox.com/ios/api/maps/5.9.0/Classes/MGLMapView.html#/c:objc(cs)MGLMapView(im)setUserTrackingMode:animated:completionHandler:

The console outputs "animation ended", but not at the end. it is displayed immediately. I think I use the completionHandler wrong. How do I use the completion handler correctly?

mapView.setUserTrackingMode(.followWithHeading, animated: true, completionHandler: {() -> Void in
            
    print("animation completed")
              
})
desmeit
  • 550
  • 1
  • 7
  • 24

1 Answers1

0

This function only works within

func mapViewDidFinishLoadingMap(_ mapView: MGLMapView) {

Before I tried it within viwDidLoad

desmeit
  • 550
  • 1
  • 7
  • 24