I have an app which uses map view. I have four locations with pins which have a title and subtitle in the call out. I have been able to add a view to leftCalloutAnnotationView but I would like to have a different view for each ppin, does anyone know how to do this? Maybe tie it to the title? Here is my code for .h and .m.
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MKAnnotationView.h>
@interface Area_One : UITableViewController <MKMapViewDelegate, MKAnnotation>{
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subtitle;
NSArray *tableData;
MKMapView *mapView;
}
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
@property (nonatomic) BOOL animatesDrop;
@property (nonatomic, retain) IBOutlet MKMapView *mapView;
@property (nonatomic, retain) NSArray *tableData;
@end
#import "Area One.h"
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#import "Location Two.h"
#import "GroupStudioThree.h"
#import "TableViewPushAppDelegate.h"
@implementation Area_One
-(id) init{
if((self = [super initWithNibName:@"Area One" bundle:nil])){
}
return self;
}
@synthesize tableData;
@synthesize mapView;
@synthesize coordinate,title,subtitle, animatesDrop;
#pragma mark -
#pragma mark Dealloc and Memory Methods
- (void)viewDidLoad {
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"TableData" ofType:@"plist"];
self.tableData = [NSArray arrayWithContentsOfFile

ath];
[mapView setMapType:MKMapTypeHybrid];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
MKCoordinateRegion region = { {0.0,0.0}, {0.0,0.0} };
region.center.latitude = 32.041586 ;
region.center.longitude = -110.773945;
region.span.longitudeDelta = 0.10f;
region.span.latitudeDelta = 0.10f;
[mapView setRegion:region animated:YES];
[mapView setDelegate:self];
Area_One *ann = [[Area_One alloc] init];
ann.title = @"Main Entrance";
ann.subtitle = @"Houghton Road";
ann.coordinate = region.center;
[mapView addAnnotation:ann];
MKCoordinateRegion region1 = { {0.0,0.0}, {0.0,0.0} };
region1.center.latitude = 32.048716 ;
region1.center.longitude = -110.782356;
region1.span.longitudeDelta = 0.10f;
region1.span.latitudeDelta = 0.10f;
[mapView setRegion:region1 animated:YES];
[mapView setDelegate:self];
Area_One *ann1 = [[Area_One alloc] init];
ann1.title = @"North Entrance";
ann1.subtitle = @"Brekke Road";
ann1.coordinate = region1.center;
[mapView addAnnotation:ann1];
MKCoordinateRegion region2 = { {0.0,0.0}, {0.0,0.0} };
region2.center.latitude = 32.042077 ;
region2.center.longitude = -110.790854;
region2.span.longitudeDelta = 0.10f;
region2.span.latitudeDelta = 0.10f;
[mapView setRegion:region2 animated:YES];
[mapView setDelegate:self];
Area_One *ann2 = [[Area_One alloc] init];
ann2.title = @"West Entrance";
ann2.subtitle = @"Harrison Road";
ann2.coordinate = region2.center;
[mapView addAnnotation:ann2];
MKCoordinateRegion region3 = { {0.0,0.0}, {0.0,0.0} };
region3.center.latitude = 32.044064 ;
region3.center.longitude = -110.781552;
region3.span.longitudeDelta = 0.10f;
region3.span.latitudeDelta = 0.10f;
[mapView setRegion:region3 animated:YES];
[mapView setDelegate:self];
Area_One *ann3 = [[Area_One alloc] init];
ann3.title = @"Main Ticket Entrance";
ann3.subtitle = @"Houghton Parking Area";
ann3.coordinate = region3.center;
[mapView addAnnotation:ann3];
}
-(MKAnnotationView *)mapView

MKMapView *) mV viewForAnnotation:
(id <MKAnnotation>)annotation {
MKPinAnnotationView *pinView = nil;
if(annotation !=mapView.userLocation)
{
static NSString *defaultPinID = @"com.invasivecode.pin";
pinView = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:defaul tPinID];
if (pinView == nil) pinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
pinView.pinColor = MKPinAnnotationColorRed;
pinView.canShowCallout = YES;
pinView.animatesDrop = YES;
UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"VisualOne.png"]];
myImageView.frame = CGRectMake (0,0,31,31);
pinView.leftCalloutAccessoryView = myImageView;
[myImageView release], myImageView = nil;
}
else {
[mapView.userLocation setTitle:@"I am here"];
}
return pinView;
self.title = @"Entrances";
}
#pragma mark -
#pragma mark Memory management
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Relinquish ownership any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
// For example: self.myOutlet = nil;
}
- (void)dealloc {
/*
[imagesArray release];
[array release];
*/
[super dealloc];
}
@end