UISwitch Doesn't Send valueChanged Event When Changed Programmatically

后端 未结 1 1255
悲&欢浪女
悲&欢浪女 2021-01-17 17:41

I have a pair of UISwitches hooked up to a IBAction via the valueChanged event. The valueChanged event is firing fine when the switches are touched. However, if I change one

相关标签:
1条回答
  • 2021-01-17 17:42

    This is correct and desired behavior. Since you explicitly changed the value, it is up to you to decide how to handle the changed value.

    The reason for this is because it is not uncommon to explicitly change the value of control after being notified of its value being changed through user interaction. If the explicit state change caused the event to fire again, you would end up in an infinite loop.

    0 讨论(0)
提交回复
热议问题