2

I see many examples on how to add a callout accessory view to an annotation:

        UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
        [rightButton addTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];
        annotationView.rightCalloutAccessoryView = rightButton;

However that gives me a blue info button:

enter image description here

But I really want the grey arrow button:

enter image description here

Is there a way to get this type of button from the SDK. I tried all the button types defined in UIButton, but no luck.

lostintranslation
  • 23,756
  • 50
  • 159
  • 262
  • Unfortunately, detail disclosure button style is not available in iOS7 (see http://stackoverflow.com/questions/22012468/mkannotationview-always-shows-infobutton-instead-of-detaildisclosure-btn). Instead, use a button with a gray arrow image. Also, setting the target and action to nil doesn't make sense (implementing the calloutAccessoryControlTapped delegate method instead of a custom action is generally better anyway). –  Jul 22 '14 at 02:38

1 Answers1

3

get an image of arrow and set it in callout accessory view

UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[rightButton setImage:[UIImage imageNamed:@"abc.png"] forState:UIControlStateNormal];
[rightButton setImage:[UIImage imageNamed:@"abc.png"] forState:UIControlStateHighlighted];
[rightButton addTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
Mehul Thakkar
  • 12,440
  • 10
  • 52
  • 81