次の方法で:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
私は現在、次の22を持っています。
if ([[annotation title] isEqualToString:@"Arcadian Winery"]) {
[profileIconView setImage:[UIImage imageNamed:@"arcadian.png"]];
}
if ([[annotation title] isEqualToString: @"Babcock Winery and vineyards"]) {
[profileIconView setImage:[UIImage imageNamed:@"babcock.png"]];
}
if ([[annotation title] isEqualToString:@"Bonny Doon Vineyard"]) {
[profileIconView setImage:[UIImage imageNamed:@"bonnyDoon.png"]];
}
次の配列に置き換えたいのですが、最後のオブジェクトのみを返し続けます。
NSArray *wineryTitle = [NSArray arrayWithObjects:
@"Arcadian Winery",
@"Babcock Winery and vineyards",
@"Bonny Doon Vineyard",
@"Castoro Cellars",
@"Dry Creek Vineyard",
@"Gary Farrell Wines, Inc.",
@"Equinox Methode Champenoise",
@"Figge Cellars",
@"Frog's Leap Winery",
@"Heitz Wine Cellars",
@"Kathryn Kennedy",
@"Merryvale Vineyards",
@"Manzoni Estate Vineyard",
@"Marilyn Remark Winery",
@"Bernardus Vineyards & Winery",
@"Nickel & Nickel",
@"Opolo Vineyards, Inc.",
@"Riverbench Vineyard and Winery",
@"Steven Kent Winery",
@"Storrs Winery",
@"Talley Vineyards",
@"Thomas Fogarty Winery",
nil];
NSArray *wineryImage = [NSArray arrayWithObjects:
@"arcadian.png",
@"babcock.png",
@"bonnyDoon.png",
@"castoro.png",
@"dryCreek.png",
@"garyFarrell",
@"EquinoxMethodeChampenoise.png",
@"figge.png",
@"frogsLeap.png",
@"heitz.png",
@"kathrynKennedy.png",
@"merryvale.png",
@"manzoni.png",
@"mailynRemark.png",
@"bernardus.png",
@"nickelAndNickel.png",
@"opolo.png",
@"riverbench.png",
@"stevenKent.png",
@"storrs.png",
@"talley.png",
@"thomasFogarty.png",
nil];
for (int i = 0; i < 22; i++) {
UIImageView *profileIconView = [[UIImageView alloc] init];
if ([[wineryTitle objectAtIndex:i] isEqualToString:[wineryTitle objectAtIndex:i]]) {
[profileIconView setImage:[UIImage imageNamed:[wineryImage objectAtIndex:i]]];
}
profileIconView.frame = CGRectMake(0, 0, 40, 33);
pinView.leftCalloutAccessoryView = profileIconView;
[profileIconView release];
}
return pinView;
配列はタイトルの文字列を適切にループしていますが、常に最後の画像のみを注釈に返します。