Ich muss den aktuellen Standort Benutzer pic MKView zentrieren. Aber curretnly ist es nicht in der Mitte, wie im folgenden Screenshot angegeben.So zentrieren Sie den aktuellen Standort Benutzer avtar in ios
(void)locationManager:(CLLocationManager *)manager didFailWithError: (NSError *)error
{
NSLog(@"didFailWithError: %@", error);
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
if (currentLocation != nil)
{
NSLog(@"%@",[NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude]);
NSLog(@"%@",[NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude]);
// [mkMapView setCenterCoordinate:mkMapView.userLocation.location.coordinate animated:YES];
}
}
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 150, 150);
[mkMapView setRegion:[mkMapView regionThatFits:region] animated:YES];
}
Haben Sie den Rahmen der mkmapview zurückgesetzt, nachdem Sie die Region festgelegt haben? –
Nein, ich benutze keinen Rahmen. – DJtiwari