我想補充一個觀點,當我在一個針點擊,但只顯示標題和副標題,不,我沒有補充的觀點。創建自定義調出查看
這裏是我的代碼
-(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];
}
這裏我添加自定義視圖。我把一個斷點在這裏和這個函數被調用,但是當我在針點擊,appearas只有標題和subtitle..ignoring我添加
- (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;
}
Thx,它的工作原理。但是,我如何創建更大的視圖?點擊圖釘時,我需要顯示帶有ImageViews,標籤和按鈕的100 x100視圖。這是可能的? – shadsauhduisad
我也發現,使用自定義註釋視圖這個[示例代碼(http://blog.asolutions.com/2010/09/building-custom-map-annotation-callouts-part-1/)的示例代碼。 – shadsauhduisad
正如你所看到的,內置的標註視圖並不是非常可定製的。唯一的方法是禁用它(canShowCallout = NO),並在didSelectAnnotationView中,將自定義標註視圖添加到註釋視圖本身(這是一種方法)。您找到的示例代碼似乎是一個受歡迎的選項。 – Anna