我在 UIViewController 中使用地图视图,并且我提供了一个默认位置来放大,并带有注释。但是变焦不起作用。注释工作正常,但初始缩放到位置不起作用。
我不确定是什么导致了这个问题。任何帮助将不胜感激。
这是我的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
MKCoordinateRegion myRegion;
//Center
CLLocationCoordinate2D center;
center.latitude = 39.21516;
center.longitude = -76.580806;
//Span
MKCoordinateSpan span;
span.latitudeDelta = 0.02f;
span.longitudeDelta = 0.02f;
myRegion.center = center;
myRegion.span = span;
//set mapView
[self.mapView setRegion:ascRegion animated:YES];
//Annotation
//Create coordinate for annotation
CLLocationCoordinate2D theLocation;
theLocation.latitude = 39.21516;
theLocation.longitude = -76.580806;
MyMapAnnotation * myAnnotation = [MyMapAnnotation alloc];
myAnnotation.coordinate = theLocation;
myAnnotation.title = @"I am here";
myAnnotation.subtitle = @"This is where I am";
[self.mapView addAnnotation:myAnnotation];
}