Я предполагаю, что вы показываете заголовок и подзаголовок в выноске для аннотации (серое поле, которое появляется при нажатии на булавку, если вы используете булавку). Если это так, у выноски есть два представления для настройки (leftCalloutAccessoryView и rightCalloutAccessoryView (оба устанавливаются в представлении аннотации))
ТАК, если вы хотите, чтобы изображение отображалось в сером поле над булавкой, когда вы нажимаете на булавку, вы можете сделать это, настроив представление аннотации, внедрив такой метод делегата:
-(MKAnnotationView*)mapView:(MKMapView*)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
// If you are showing the users location on the map you don't want to change it
MKAnnotationView *view = nil;
if (annotation != mapView.userLocation) {
// This is not the users location indicator (the blue dot)
view = [mapView dequeueReusableAnnotationViewWithIdentifier:@"myAnnotationIdentifier"];
if (!view) {
// Could not reuse a view ...
// Creating a new annotation view, in this case it still looks like a pin
view = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"myAnnotationIdentifier"] autorelease];
view.canShowCallOut = YES; // So that the callout can appear
UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"someName"]];
myImageView.frame = CGRectMake(0,0,31,31); // Change the size of the image to fit the callout
// Change this to rightCallout... to move the image to the right side
view.leftCalloutAccessoryView = myImageView;
[myImageView release], myImageView = nil;
}
}
return view;
}
Однако, если все, что вам нужно, это показать множество изображений непосредственно на карте (а не в выносках), вы можете, используя тот же метод делегата, установить свойство "изображение" представления аннотаций. , нравится:
-(MKAnnotationView*)mapView:(MKMapView)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
// If you are showing the users location on the map you don't want to change it
MKAnnotationView *view = nil;
if (annotation != mapView.userLocation) {
// This is not the users location indicator (the blue dot)
view = [mapView dequeueReusableAnnotationViewWithIdentifier:@"myAnnotationIdentifier"];
if (!view) {
// Could not reuse a view ...
// Creating a new annotation view
view = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"myAnnotationIdentifier"] autorelease];
// This will rescale the annotation view to fit the image
view.image = [UIImage imageNamed:@"someName"];
}
}
return view;
}
Я надеюсь, что это ответ на ваш вопрос
person
David Rönnqvist
schedule
10.02.2011