The UIControl documentation clearly states:
When a user touches a control in a way that matches one or more specific events, UIControl sends sendActionsForControlEvents: itself.
So I did pretty simple. I created a subclass of UIControl and redefined it as follows:
- (void)sendActionsForControlEvents:(UIControlEvents)controlEvents { [super sendActionsForControlEvents:controlEvents]; NSLog(@"- (void)sendActionsForControlEvents:(UIControlEvents)controlEvents"); }
Then I created an instance of UIControl and added an action-target object as:
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];
I also implemented this -anyTouch: method for the selector, for example:
- (void) anyTouch:(id)sender { NSLog(@"anyTouch"); }
What happens: I touch the view from this control, and -anyTouch displays the "anyTouch" log messages while I touch it. But even if I subclass UIControl and override sendActionsForControlEvents :, I do not receive the log message as I should. It's pointless. I rewrote it. He must record this message, damn it. %! ยง $%
HelloMoon
source share