Reputation: 12051
I'm writing my own custom control which is implemented through UIView
.
And when I initialize it, I would like to add a custom target to it like this:
[myControl addTarget:self action:@selector(turnOn) forControlEvents:UIControlEventValueChanged];
I do this so when I change something on my UIView, it would trigger that sort of method in its parent control. I am aware that there's a delegate for such purposes, but I was wondering if it is possible to do without it.
How do you do this sort of thing in Objective-C? Thanks in advance!
Upvotes: 1
Views: 1144
Reputation: 17732
If you instead subclass UIContol
you can invoke
- (void)sendActionsForControlEvents:(UIControlEvents)controlEvents
from within your subclass, and that will trigger the action
Upvotes: 1