Implementing an onValueChange for a UISwitch in OBJ-C but not when the user touches/changes the value

StackOverflow https://stackoverflow.com/questions/21587492

سؤال

Is there way to implement an onValueChange listener in Xcode/Objective C for an UISwitch but not an onTouch listener? So I want a method to be called when the value of the UISwitch changes without user input. (This will happen programatically via a text SMS service)

هل كانت مفيدة؟

المحلول

The listener is only called when the UISwitch gets toggled by the user touching it. If you programmatically set it, the listener won't be called. But since you're programmatically changing it, just call your listener yourself at the time you change it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top