The UIControl documentation clearly states:
When a user touches the control in a way that corresponds to one or more specified events, UIControl sends itself sendActionsForControlEvents:.
So what I did is pretty simple. I created a UIControl subclass, and overrided this, like this:
- (void)sendActionsForControlEvents:(UIControlEvents)controlEvents {
[super sendActionsForControlEvents:controlEvents];
NSLog(@"- (void)sendActionsForControlEvents:(UIControlEvents)controlEvents");
}
Then I instantiated my custom UIControl and added a action-target-thing like this:
MyCustomControl *twb = [[MyCustomControl alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 80.0f, 80.0f)];
twb.backgroundColor = [UIColor yellowColor];
[twb addTarget:self action:@selector(anyTouch:) forControlEvents:UIControlEventAllTouchEvents];
[self addSubview:twb];
also, I implemented that -anyTouch: method for the selector, like this:
- (void) anyTouch:(id)sender {
NSLog(@"anyTouch");
}
What happens: I touch the view from that control, and -anyTouch throws out the "anyTouch" log messages while I am touching around on it. But even though I subclassed UIControl and overrided that sendActionsForControlEvents:, I don't get the log message like I should. That makes no sense. I've overwritten it. It should log that message, damn it. %!§$%