It depends what kind of button you set on the rightCalloutAccessoryView
. E.g. if you use:
[UIButton buttonWithType:UIButtonTypeDetailDisclosure];
Then both tapping the callout and tapping the button both result in calloutAccessoryControlTapped
being called with the button. But if you use:
[UIButton systemButtonWithImage:[UIImage systemImageNamed:@"info.circle"] target:nil action:nil];
Then only tapping the button will work, tapping the callout will be disabled.
If you have a custom button and you want the first behavior then you can make a button subclass and do this:
@interface UIButton2 : UIButton
@end
@implementation UIButton2
- (id)_mapkit_accessoryControlToExtendWithCallout{
return self;
}
@end
This private method is how it decides wether a button should also work for tapping the callout (learned this using Hopper). The default implementation checks self.buttonType
to decide.
A more sensible way would be to start with the disclosure button and change its image, e.g.
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
UIImage *image = [UIImage systemImageNamed:@"chevron.right" withConfiguration:[UIImageSymbolConfiguration configurationWithScale:UIImageSymbolScaleSmall];
[button setImage:image forState:UIControlStateNormal];
A lot of this weird behaviour is likely to do with changes in how callout buttons work since iOS 6.