I have a custom class of a UIView I’ve made inside my viewcontroller. I want to make this class re-usable and so don’t want to build it to work just with this 1 viewcontroller. Because of this, I think the best way of telling my viewcontroller that the user has interacted with the class is to somehow make my own UIControlEvent. Maybe something like:
[customClass addTarget:self action:@selector(whatIWantToHappen) forControlEvents:UIControlEventWhatever];
I don’t know much about doing this though, any suggestions on this?
You could do this by subclassing
UIControl, which inherits from UIView, but provides some additional methods for handling targets and actions. Have a look at the constants, perhaps one of the predefined control events already fits your bill. Otherwise, you could define your own events in the range provided byUIControlEventApplicationReserved, you should however never prefix your own things withUI..., that ‘namespace’ is reserved for UIKit.