Reputation: 434
Code from my custom MKAnnotationView:
- (id)initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
if (self) {
self.canShowCallout = YES;
_pinView = [[CustomPinView alloc] init];
[self addSubview:_pinView];
}
return self;
}
Code from my VC:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{
MapAnnotationView *pinView = nil;
pinView = (MapAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"lol"];
if (pinView == nil){
pinView = [[MapAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"lol"];
}
return pinView;
}
What am I doing wrong, pls help me.
Upvotes: 0
Views: 830
Reputation: 434
Allright, I'll do it by myself.
You should set image to your custom MKAnnotationView with size of subviews.
You should set canShowCallout = YES only if your MKPointAnnotation has description string (not nil, or @""), otherwise you should set canShowCallout = NO
After that method didSelectAnnotationView will be called. Hope it helps for someone.
Upvotes: 2