Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 282
Christian Gossain Avatar asked Jun 29 '13 23:06

Christian Gossain


1 Answers

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.

Use this function where you deem should trigger a value has changed

like image 79
rmaddy Avatar answered Sep 20 '22 13:09

rmaddy