做到了!!很高兴。我根据按下的按钮从前一个视图传递不同的坐标,并使用 IF 语句将这些坐标固定在下一个视图上。对于编程大师来说,这无疑是一件简单的事情,但我没有经验,所以我很高兴:)
-(void)viewWillAppear:(BOOL)animated
{
CLLocationCoordinate2D location;
NSLog(@"self.stringToDisplay = %@", self.stringToDisplay);
if ([self.stringToDisplay isEqualToString: @"44.48, -73.21"])
{
location.latitude = (double) 44.4758;
location.longitude = (double) -73.2125;
MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Burlington, VT" andCoordinate:location];
[self.mapView addAnnotation:newAnnotation];
}
if ([self.stringToDisplay isEqualToString: @"51.50, -0.14"])
{
location.latitude = (double) 51.5010;
location.longitude = (double) -0.1425;
MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Buckingham Palace" andCoordinate:location];
[self.mapView addAnnotation:newAnnotation];
}
}