Skip to content

Instantly share code, notes, and snippets.

@ryanbaldwin
Last active December 24, 2015 20:59
Show Gist options
  • Save ryanbaldwin/6862075 to your computer and use it in GitHub Desktop.
Save ryanbaldwin/6862075 to your computer and use it in GitHub Desktop.
Trying to add a UIButtonTypeRoundedRect to an annotation view. Everything shows up fine (title and subtitle), and there's space to the right of the details where you'd expect the button to be, but the actual button itself never shows up. Any ideas?
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
MKPinAnnotationView *annotationView = nil;
if(annotation != mapView.userLocation) {
static NSString *reuseId = @"annotationView";
annotationView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:reuseId];
if(!annotationView) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseId];
}
annotationView.canShowCallout = YES;
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
infoButton.frame = CGRectMake(0, 0, 22, 22);
annotationView.rightCalloutAccessoryView = infoButton;
}
return annotationView;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment