adirbuilder adirbuilder - 1 year ago 192
iOS Question

User Tracking Mode Missing Animation, swift

I have This code here including

userTrackingMode = .follow
and it works great but it just pops onto user location instead of animating the map to go to the user location ...which is what i want . Anyone can tell me hot to add that animation making the map change onto the user location by animation and not just pop onto it ( if it makes sense )

import UIKit
import MapKit
import CoreLocation

class MapViewController: UIViewController,MKMapViewDelegate, CLLocationManagerDelegate{

@IBOutlet weak var mapView: MKMapView!

@IBAction func UserTrackingMode(sender: AnyObject) {

mapView.userTrackingMode = .Follow

Answer Source

You to call setUserTrackingMode:animated in order to animate the transition:

@IBAction func UserTrackingMode(sender: AnyObject) {

    mapView.setUserTrackingMode(.Follow, animated:true)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download