sau khi tôi dành 2 ngày tìm kiếm lỗi tôi phải yêu cầu trợ giúp tại đây. tôi có MapViewController và đặt một số chân trên bản đồ. Tôi đã sao chép hầu hết mã từ MapCallouts và WeatherMap của các mẫu mã táo.MKAnnotationXem chế độ xemCho phép không bao giờ được gọi là
dù sao có vẻ như tôi đã xóa hoặc bỏ lỡ các phần thiết yếu. có vẻ như không có mối liên hệ giữa các MapViewController và đoạn mã sau
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
NSLog(@"MKAnnotationView");
return nil;
}
thiết lập một chú thích trông như thế này và nó hoạt động tốt:
- (void)createPoi:(CLLocationCoordinate2D)theCoordinate
{
NSLog(@"createPoi");
RandomAnnotation *randomAnnotation = [[RandomAnnotation alloc] init];
[randomAnnotation setTheCoordinate:theCoordinate];
[randomAnnotation setTheTitle:@"bla"];
[randomAnnotation setTheSubTitle:@"bla"];
[self.mapAnnotations insertObject:randomAnnotation atIndex:kRandomAnnotationIndex];
[randomAnnotation release];
[self.mapView addAnnotation:[self.mapAnnotations objectAtIndex:kRandomAnnotationIndex]];
}
tôi không thể tìm ra những gì là sai. ai có thể cho tôi một gợi ý những gì còn thiếu? tôi phải thừa nhận rằng tôi không có bất kỳ kinh nghiệm với mô hình đại biểu.
aah. Vâng! tôi quên để treo bản đồ trong IB để đại diện chủ sở hữu của tập tin. xấu hổ với tôi: -/ vấn đề được giải quyết! cảm ơn bạn rất nhiều vì sự trợ giúp nhanh chóng của bạn !!! :-) – rockstarberlin