Skip to content

Instantly share code, notes, and snippets.

@jbrennan
Created June 20, 2014 15:16
Show Gist options
  • Save jbrennan/36634a7a1cc15b6b4a7d to your computer and use it in GitHub Desktop.
Save jbrennan/36634a7a1cc15b6b4a7d to your computer and use it in GitHub Desktop.
Gesture initializer
@implementation UIGestureRecognizer (ForDummies)
+ (instancetype)newWithView:(UIView *)view target:(id)target action:(SEL)action delegate:(id<UIGestureRecognizerDelegate>)delegate
{
UIGestureRecognizer *gesture = [[[self class] alloc] initWithTarget:target action:action];
gesture.delegate = delegate;
[view addGestureRecognizer:gesture];
view.userInteractionEnabled = YES;
return gesture;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment