HowTo initialise MKMapView with a given user location?

后端 未结 4 455
滥情空心
滥情空心 2020-12-04 09:14

My app knows the current user position (CoreLocation.framework). As soon as the user opens a new MapView his iPhone starts searching for the current position again. Is it p

4条回答
  •  星月不相逢
    2020-12-04 09:35

    In your controller:

    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        CLLocationCoordinate2D coord = {latitude: 37.423617, longitude: -122.220154};
        MKCoordinateSpan span = {latitudeDelta: 1, longitudeDelta: 1};
        MKCoordinateRegion region = {coord, span};
        [mapView setRegion:region];
    }
    

    When map appears it's going to be centered close to Palo Alto

提交回复
热议问题