How to center my current location in MKMapView?

后端 未结 4 1608
谎友^
谎友^ 2021-01-31 05:11

I am showing the current location in MKMapView by using showUserLocation enables. I also want to center the mapview to the us

4条回答
  •  抹茶落季
    2021-01-31 06:05

    For centering on user location, you can use the following code:

    [mapView setCenterCoordinate:mapView.userLocation.location.coordinate animated:YES];
    

    For zooming on special locations, you should study how the regions (MKCoordinateRegion) are counted and work, count your values for the region and display it using call:

    [mapView setRegion:myRegion animated:YES];
    

    This sample WorldCities shows basics of region displaying.

提交回复
热议问题