2016-05-01 13 views
-1

Ich habe eine normale MKMap-Ansicht mit einer grundlegenden MKAnnoation, was ich erreichen möchte, ist, dass meine Anmerkung in Großbritannien ist und der MKCoordinateSpan 0,05 ist, aber ich möchte das MKMapView von einer Ansicht starten des gesamten Vereinigten Königreichs und zoomen in die Anmerkung hinein.Wie man ein MKMapView von oben kommt

Antwort

0
- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 
    /* set here the region from where map will be zooming; */ 
    [self.mapView setRegion:MKCoordinateRegionForMapRect(MKMapRectWorld) animated:NO]; 
} 

- (void)viewDidAppear:(BOOL)animated { 
    [super viewDidAppear:animated]; 
    /* set here your end point of zooming */ 
    CLLocationCoordinate2D zoomLocation; 
    zoomLocation.latitude = 39.281516; 
    zoomLocation.longitude= -76.580806; 

    [self.mapView setCenterCoordinate:zoomLocation animated:YES]; 
    CLLocationDistance locationDistance = [self locationDistance:0.5]; 
    MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, locationDistance, locationDistance); 
    [self.mapView setRegion:viewRegion animated:YES]; 
} 

- (CLLocationDistance)locationDistance:(CGFloat)value { 
    return 1609.344 *value; 
}