I have a UIButton
that is only reacting to my tap gestures when I tap on a very small sub-area within it. I'm assuming that maybe another view is swallowing my gestures when I tap in other places within the button.
the question is.. is there a way to know which UIView
exactly is receiving the taps? I know I can brute force it an attach all gesture handlers to all of my views.. but seems like too much work. any ideas?
update: Ahmed's answer below worked perfectly.. I also added to it UIView's recursiveDescription to find the offending view quickly.
ie if i put a breakpoint on the NSLog line:
- (void)sendEvent:(UIEvent *)event
{
[super sendEvent:event];
UIView *touchReceipientView =((UITouch *)[event.allTouches anyObject]).view;
NSLog(@"View = %@ ",touchReceipientView);
}
I get this output (as an example):
(lldb) po [touchReceipientView recursiveDescription]
<UIView: 0x1fd16470; frame = (0 430; 320 40); layer = <CALayer: 0x1fd164d0>>
| <UIButton: 0x1fd13030; frame = (297 0; 18 19); opaque = NO; tag = 11; layer = <CALayer: 0x1fd130f0>>
| | <UIImageView: 0x1fd13190; frame = (-41 -40.5; 100 100); alpha = 0; opaque = NO; userInteractionEnabled = NO; tag = 1886548836; layer = <CALayer: 0x1fd131f0>>
| | <UIImageView: 0x1fd14d00; frame = (1 2; 16 15); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1fdc8e50>>
which made me identify the offending UIView immediately!