Reputation: 1957
UIButton has a state property, which appears to be KVO compliant by all accounts and there is no documentation to indicate otherwise. However, when I added an observer to a UIButton's state property, the observer callback was never invoked. How come?
Upvotes: 10
Views: 6236
Reputation: 3672
If you look at the documentation of UIControl, the state property is marked: synthesized from other flags.
I guess this is why changes to this property are not KVO compliant.
However, you can simply register and observer for the values you need - highlighted, selected, enabled.
These properties are KVO compliant and you will get the observer callback when they change.
Upvotes: 23