Skip to content

Instantly share code, notes, and snippets.

@abbeyjackson
Created September 16, 2015 16:59
Show Gist options
  • Save abbeyjackson/69f07ccd7e0846c5573f to your computer and use it in GitHub Desktop.
Save abbeyjackson/69f07ccd7e0846c5573f to your computer and use it in GitHub Desktop.
NSLog / print out what UI element you tap. For finding what code / method / function belongs to what element. From Aryan Ghassemi in ios-dev slack
- (void)viewDidLoad {
[super viewDidLoad];
[self addGesture:self.view];
}
- (void)addGesture:(UIView *)aView {
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didDetectClick:)];
[aView addGestureRecognizer:gesture];
for (UIView *subView in aView.subviews) {
[self addGesture:subView];
}
}
- (void)didDetectClick:(UITapGestureRecognizer *)tap {
NSLog(@"%@", tap.view);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment