How can I send a “UIControlEventValueChanged” event from my custom control?

会有一股神秘感。 提交于 2019-12-03 14:37:32

问题


I've created a custom picker view type of control by subclassing UIView. I would like to be able to send a "UIControlEventValueChanged" control event from within this control, so that I can register for it in whichever view controller is using the control.

How can I can I get my custom control to trigger this event when I deem it should be triggered?


回答1:


Assuming your custom control extends UIControl, then you simply do:

[self sendActionsForControlEvents:UIControlEventValueChanged];

This will call all registered targets (via addTarget:action:forControlEvents: that this event has happened.



来源:https://stackoverflow.com/questions/17385614/how-can-i-send-a-uicontroleventvaluechanged-event-from-my-custom-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!