UIViewController <MKMapViewDelegate, MKReverseGeocoderDelegate> {
...
}
- (void)viewDidLoad {
MKCoordinateRegion seoulRegion;
CLLocationCoordinate2D center;
center.latitude = 37.47783;
center.longitude = 127.044060;
MKCoordinateSpan span;
span.latitudeDelta = 0.005;
span.longitudeDelta = 0.005;
seoulRegion.center = center;
seoulRegion.span = span;
mapView.region = seoulRegion;
NSMutableArray *annotations = [[NSMutableArray alloc] init];
CLLocationCoordinate2D coord2d = {37.47783,127.044060};
MyAnnotation *anno = [[MyAnnotation alloc] initWithCoords:coord2d name:@"name1"];
anno.title = @"title1";
anno.subtitle = @"subtitle1";
[annotations addObject:anno];
[anno release];
CLLocationCoordinate2D coord2d1 = {37.480783,127.046060};
MyAnnotation *anno1 = [[MyAnnotation alloc] initWithCoords:coord2d1 name:@"name2"];
anno1.title = @"title2";
anno1.subtitle = @"subtitle2";
[annotations addObject:anno1];
[anno1 release];
[mapView addAnnotations:annotations];
[annotations release];
[super viewDidLoad];
}
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>) annotation
{
MKPinAnnotationView *annoView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:[annotation title]];
annoView.animatesDrop = YES;
UIButton *addButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annoView.rightCalloutAccessoryView = addButton;
[annoView setCanShowCallout:YES];
[annoView setSelected:YES animated:YES];
[annoView release];
return annoView;
}
'Object-C' 카테고리의 다른 글
NSNotificationCenter (0) | 2010.10.10 |
---|---|
MoviePlayer (0) | 2010.10.09 |
XML (0) | 2010.10.09 |
SQLITE (0) | 2010.10.08 |
CoreData (0) | 2010.10.07 |