Ios – Center the MKMapView onto the location when pressing a button

iosmkmapview

My app includes an MKMapView that shows the users location as a blue bullet.

Now I made a button (just like in a normal map app) that when pressed should center the map view onto the users location, but I don't know how to do so.

Best Answer

You could just set map view user tracking mode to MKUserTrackingModeFollow. It would automatically set map center on user location.

- (IBAction)centerMapOnUserButtonClicked:(id)sender {
    [self.mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES]; 
}