How to center my current location in MKMapView?

后端 未结 4 1687
谎友^
谎友^ 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 05:57

    -(void) removeZoom:(float)deltaValue
    {
        MKCoordinateRegion region;
        region.center.latitude =  self.locationManager.location.coordinate.latitude;
        region.center.longitude = self.locationManager.location.coordinate.longitude;
    
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        region.span.latitudeDelta = deltaValue;
        region.span.longitudeDelta = deltaValue;
        region = [mapViewSelf regionThatFits:region];
        [mapViewSelf setRegion:region animated:YES];
        [UIView commitAnimations];
    
    }
    

提交回复
热议问题