Reputation: 11134
I have a map view and a custom callout built from scratch. Everything works fine except that the callout disappears whenever user taps on it.
Upvotes: 0
Views: 216
Reputation: 11134
First, make sure you override pointInside
in your custom annotation view to account for the callout:
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
if self.bounds.contains(point) {
return true
} else {
return self.subviews.contains { $0.frame.contains(point) }
}
}
Then, map view turns out to favour UIButton
in a callout and won't dismiss if the tap hits an instance of UIButton
. Make sure that you cover the whole callout view with a button (which may or may not do anything when tapped).
You can add subviews into a UIButton
, but make sure that they all have isUserInteractionEnabled
set to false
.
Upvotes: 0