I have custom class, which has UIView. I want it to do action, when the view is tapped. When i add:
[(UIControl*)customClass addTarget:self
action:@selector(doAction:)
forControlEvents:UIControlEventAllTouchEvents];
"doAction" is fireing sometimes when i click the view, however mostly not. But I've noticed that if i add:
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doAction:)];
[(UIControl*)customClass addGestureRecognizer:tapGesture];
What is the difference between these two recognizers? I know, that UIControl has delegates and UIGestureRecognizer, but can't understand why control isn't always catching touch.
The problem is that my sender in case of gestureRecognizer is wrong, because i can't pull some data from it.
- (void)doAction:(customClass*)sender {
switch (sender.actionType) { // do something ... } }
How to access it? Structure shown in breakpoint is like this:
sender -> UIGestureRecognizer -> _view -> _actionType