一旦单击它,我正在努力在 MapView 中设置注释的副标题。
米:
MKCoordinateRegion England = { {0.0, 0.0} , {0.0, 0.0} };
England.center.latitude = 51.50063;
England.center.longitude = -0.124629;
England.span.longitudeDelta = 100.0f;
England.span.latitudeDelta = 100.0f;
[mapView setRegion:England animated:YES];
Annotation *ann1 = [[Annotation alloc] init];
ann1.title = @"England";
ann1.subtitle = @"subtitle";
ann1.coordinate = England.center;
[mapView addAnnotation:ann1];
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation: (id<MKAnnotation>)annotation {
MKPinAnnotationView *MyPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"current"]; MyPin.pinColor = MKPinAnnotationColorPurple;
UIButton *advertButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[advertButton addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
MyPin.rightCalloutAccessoryView = advertButton;
MyPin.draggable = NO;
MyPin.highlighted = YES;
MyPin.animatesDrop = TRUE;
MyPin.canShowCallout = YES;
return MyPin;
}
- (void)mapView:(MKMapView *)mapView1 didSelectAnnotationView:(MKAnnotationView *)view
{
id<MKAnnotation> selectedAnn = [mapView.selectedAnnotations objectAtIndex:0];
country_title = selectedAnn.title;
selectedAnn.subtitle = @"NEW SUBTITLE";
}
单击注释后如何设置字幕?我不想那样做,因为我在点击 mysql 时会从 mysql 中得到一些行。但我不知道如何更新特定注释的字幕?
提前致谢!:)