5
上我想我的標註地圖MKPointAnnotation
,像這樣:MKAnnotationView沒有顯示出來的地圖
- (void)viewDidLoad
{
NSLog(@"RootViewController viewDidLoad");
[super viewDidLoad];
CLLocationCoordinate2D coord =
CLLocationCoordinate2DMake(54.903683,23.895435);
MKPointAnnotation *toyAnnotation = [[MKPointAnnotation alloc] init];
toyAnnotation.coordinate = coord;
toyAnnotation.title = @"Title";
toyAnnotation.subtitle = @"Subtitle";
[mapView addAnnotation:toyAnnotation];
[toyAnnotation release];
}
- (MKAnnotationView *)mapView:(MKMapView *)m
viewForAnnotation:(id <MKAnnotation>)annotation
{
NSLog(@"RootViewController mapView: viewForAnnotation:");
NSLog(@"%@",annotation);
MKAnnotationView *pin = [[MKAnnotationView alloc]
initWithAnnotation:annotation
reuseIdentifier:nil];
pin.enabled = YES;
pin.canShowCallout = YES;
return [pin autorelease];
}
針沒有出現在地圖上。 RootViewController
是mapView
委託,因此mapView:viewForAnnotation:
方法被調用:
2011-11-24 15:04:03.808 App[2532:707] RootViewController mapView: viewForAnnotation:
2011-11-24 15:04:03.810 App[2532:707] <MKPointAnnotation: 0x1885c0>
什麼我做錯了,如何解決這個問題?