ピンをクリックしてビューを追加しようとしていますが、追加したビューではなく、タイトルとサブタイトルのみが表示されます。
これが私のコードです
-(void) inserirMapa {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
NSMutableArray *pins = [[NSMutableArray alloc]init]; //array de Annotations
for(int iCnt = 0; iCnt < [_listaPins count]; iCnt++) {
Pin *pin = (Pin *) [_listaPins objectAtIndex:iCnt];
CLLocationCoordinate2D start;
start.latitude = pin.place.latitude;
start.longitude = pin.place.longitude;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(start, 800, 800);
[_myMapView setRegion:[_myMapView regionThatFits:region] animated:YES];
// Add an annotation
MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
point.coordinate = start;
point.title = @"Where am I?";
point.subtitle = @"I'm here!!!";
[_myMapView addAnnotation:point];
[pins addObject:point];//adiciona a annotation no array
[point release];
}
self.myAnnotations= [NSArray arrayWithArray:pins]; //diz que o array myAnnotations é igual ao array estacionamentos(que contem as annotations
[pins release];
[self configurarZoomDoMapaComLatitude:appDelegate.latitude eLongitude:appDelegate.longitude]; //configura o Zoom inicial do mapa
[_myMapView addAnnotations:_myAnnotations];
[_viewLoading setHidden:YES];
}
ここで、カスタム ビューを追加します。ここにブレークポイントを配置すると、この関数が呼び出されますが、ピンをクリックすると、タイトルとサブタイトルのみが表示され、追加したビューは無視されます
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView* annotationView = nil;
//your code
UIView *vw = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
vw.backgroundColor = [UIColor redColor];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 50, 50)];
label.numberOfLines = 4;
label.text = @"hello\nhow are you\nfine";
[vw addSubview:label];
annotationView.leftCalloutAccessoryView = vw;
return annotationView;
}