MKMapViewDelegate
을 구현하는 클래스를 하위 클래스로 지정합니다. 수퍼 클래스에서 위임자도 설정하고 있지만 -(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
메서드는 호출되지 않습니다. 여기 내 코드는하지만MKMapViewDelegate를 구현하는 클래스를 상속 받지만 MKMapViewDelegate 메서드는 호출되지 않습니다.
내 슈퍼 클래스 코드
// RecentPhotosMapViewController.h
@interface RecentPhotosMapViewController : UIViewController <MKMapViewDelegate>
@property (nonatomic,strong) NSArray *annotations;
@property(nonatomic,weak) IBOutlet MKMapView *mapView;
@end
// RecentPhotosMapViewController.m
- (void)viewDidLoad{
[super viewDidLoad];
// Do any additional setup after loading the view.
// load annotation data
self.mapView.delegate = self;
}
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation: (id<MKAnnotation>)annotation{
MKAnnotationView *aView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"MapVC"];
// safety code
if(!aView){
aView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MapVC"];
aView.canShowCallout = YES;
aView.leftCalloutAccessoryView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
aView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
}
aView.annotation = annotation;
[(UIImageView *)aView.leftCalloutAccessoryView setImage:nil];
return aView;
}
내 서브 클래스 코드
// RecentPhotosMapViewControllerWithAnnotationData.h
@interface RecentPhotosMapViewControllerWithAnnotationData : RecentPhotosMapViewController
@end
RecentPhotosMapViewControllerWithAnnotationData.m 파일
-(void) viewDidLoad{
// extract annotation data.....
// set zoom level
[super viewDidLoad];
}
-(void) mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view method is called
도움이 되셨습니다.
감사는 도움이되지만 처음 난 내 [슈퍼 전에 내 모달을 설정해야 viewDidLoad] 내 하위 클래스에서 다른 제안이 호출됩니다. – shaunak1111
왜 그렇게하고 있는지 재검토하고 싶을 수도 있지만 '[super viewDidLoad]; 앞에 물건을 옮길 수는 있지만 원하는 것을 더 잘 수행 할 수 있다는 것을 명심하십시오. – Ric