Erik
Erik

Reputation: 2530

MKAnnotationView subclass with custom isSelected setter is not called

I've subclassed MKAnnotationView and created a custom setter on the isSelected property, but it doesn't fire. I've tried doing the same on the isHighlighted property where it gets called as expected.

Logging isSelected from another function before and after a selection occurs fields true and false as expected.

Why isn't the setter called?

internal final class CustomView: MKAnnotationView {
    override var isSelected: Bool {
        didSet {
            print("selected: \(isSelected)")
        }
    }
}

Upvotes: 1

Views: 182

Answers (1)

radutzan
radutzan

Reputation: 342

I had the same problem—just override setSelected(_ selected: Bool, animated: Bool) instead.

Upvotes: 1

Related Questions