UIView+GestureCallback.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // UIView+GestureCallback.h
  3. //
  4. // Created by Onur Ersel on 01/07/15.
  5. // Copyright (c) 2015 Onur Ersel. All rights reserved.
  6. //
  7. //https://github.com/onurersel/UIView-GestureCallback
  8. #import <UIKit/UIKit.h>
  9. @interface GestureCallbackValues : NSObject
  10. @property (nonatomic, copy) void (^tapCallback)(UITapGestureRecognizer* recognizer, NSString* gestureId);
  11. @property (nonatomic, copy) void (^pinchCallback)(UIPinchGestureRecognizer* recognizer, NSString* gestureId);
  12. @property (nonatomic, copy) void (^panCallback)(UIPanGestureRecognizer* recognizer, NSString* gestureId);
  13. @property (nonatomic, copy) void (^swipeCallback)(UISwipeGestureRecognizer* recognizer, NSString* gestureId);
  14. @property (nonatomic, copy) void (^rotationCallback)(UIRotationGestureRecognizer* recognizer, NSString* gestureId);
  15. @property (nonatomic, copy) void (^longPressCallback)(UILongPressGestureRecognizer* recognizer, NSString* gestureId);
  16. @property (nonatomic, retain) UIGestureRecognizer *gesture;
  17. @property (nonatomic, retain) NSString *gestureId;
  18. @end
  19. @interface UIView (GestureCallback)
  20. @property (nonatomic) NSMutableDictionary *gestures;
  21. @property (nonatomic) NSMutableDictionary *gestureKeysHash;
  22. // tap
  23. -(NSString*)addTapGestureRecognizer:(void(^)(UITapGestureRecognizer* recognizer, NSString* gestureId))tapCallback;
  24. -(NSString*)addTapGestureRecognizer:(void(^)(UITapGestureRecognizer* recognizer, NSString* gestureId))tapCallback numberOfTapsRequired:(NSUInteger)numberOfTapsRequired numberOfTouchesRequired:(NSUInteger)numberOfTouchesRequired;
  25. -(void)addTapGestureRecognizer:(void(^)(UITapGestureRecognizer* recognizer, NSString* gestureId))tapCallback tapGestureId:(NSString*)tapGestureId;
  26. -(void)addTapGestureRecognizer:(void(^)(UITapGestureRecognizer* recognizer, NSString* gestureId))tapCallback tapGestureId:(NSString*)tapGestureId numberOfTapsRequired:(NSUInteger)numberOfTapsRequired numberOfTouchesRequired:(NSUInteger)numberOfTouchesRequired;
  27. -(void)removeTapGesture:(NSString*)tapGestureId;
  28. -(void)removeAllTapGestures;
  29. -(void)tapHandler:(UITapGestureRecognizer*)recognizer;
  30. // pinch
  31. -(NSString*)addPinchGestureRecognizer:(void(^)(UIPinchGestureRecognizer* recognizer, NSString* gestureId))pinchCallback;
  32. -(void)addPinchGestureRecognizer:(void(^)(UIPinchGestureRecognizer* recognizer, NSString* gestureId))pinchCallback pinchGestureId:(NSString*)pinchGestureId;
  33. -(void)removePinchGesture:(NSString*)pinchGestureId;
  34. -(void)removeAllPinchGestures;
  35. -(void)pinchHandler:(UIPinchGestureRecognizer*)recognizer;
  36. // pan
  37. -(NSString*)addPanGestureRecognizer:(void(^)(UIPanGestureRecognizer* recognizer, NSString* gestureId))panCallback;
  38. -(NSString*)addPanGestureRecognizer:(void(^)(UIPanGestureRecognizer* recognizer, NSString* gestureId))panCallback minimumNumberOfTouches:(NSUInteger)minimumNumberOfTouches maximumNumberOfTouches:(NSUInteger)maximumNumberOfTouches;
  39. -(void)addPanGestureRecognizer:(void(^)(UIPanGestureRecognizer* recognizer, NSString* gestureId))panCallback panGestureId:(NSString*)panGestureId minimumNumberOfTouches:(NSUInteger)minimumNumberOfTouches maximumNumberOfTouches:(NSUInteger)maximumNumberOfTouches;
  40. -(void)removePanGesture:(NSString*)panGestureId;
  41. -(void)removeAllPanGestures;
  42. -(void)panHandler:(UIPanGestureRecognizer*)recognizer;
  43. //swipe
  44. -(NSString*)addSwipeGestureRecognizer:(void(^)(UISwipeGestureRecognizer* recognizer, NSString* gestureId))swipeCallback direction:(UISwipeGestureRecognizerDirection)direction;
  45. -(NSString*)addSwipeGestureRecognizer:(void(^)(UISwipeGestureRecognizer* recognizer, NSString* gestureId))swipeCallback direction:(UISwipeGestureRecognizerDirection)direction numberOfTouchesRequired:(NSUInteger)numberOfTouchesRequired;
  46. -(void)addSwipeGestureRecognizer:(void(^)(UISwipeGestureRecognizer* recognizer, NSString* gestureId))swipeCallback swipeGestureId:(NSString*)swipeGestureId direction:(UISwipeGestureRecognizerDirection)direction numberOfTouchesRequired:(NSUInteger)numberOfTouchesRequired;
  47. -(void)removeSwipeGesture:(NSString*)swipeGestureId;
  48. -(void)removeAllSwipeGestures;
  49. -(void)swipeHandler:(UISwipeGestureRecognizer*)recognizer;
  50. //rotation
  51. -(NSString*)addRotationGestureRecognizer:(void(^)(UIRotationGestureRecognizer* recognizer, NSString* gestureId))rotationCallback;
  52. -(void)addRotationGestureRecognizer:(void(^)(UIRotationGestureRecognizer* recognizer, NSString* gestureId))rotationCallback rotationGestureId:(NSString*)rotationGestureId;
  53. -(void)removeRotationGesture:(NSString*)rotationGestureId;
  54. -(void)removeAllRotationGestures;
  55. -(void)rotationHandler:(UIRotationGestureRecognizer*)recognizer;
  56. //long press
  57. -(NSString*)addLongPressGestureRecognizer:(void(^)(UILongPressGestureRecognizer* recognizer, NSString* gestureId))longPressCallback;
  58. -(NSString*)addLongPressGestureRecognizer:(void(^)(UILongPressGestureRecognizer* recognizer, NSString* gestureId))longPressCallback
  59. numberOfTapsRequired:(NSUInteger)numberOfTapsRequired
  60. numberOfTouchesRequired:(NSUInteger)numberOfTouchesRequired
  61. minimumPressDuration:(CFTimeInterval)minimumPressDuration
  62. allowableMovement:(CGFloat)allowableMovement;
  63. -(void)addLongPressGestureRecognizer:(void(^)(UILongPressGestureRecognizer* recognizer, NSString* gestureId))longPressCallback
  64. longPressGestureId:(NSString*)longPressGestureId
  65. numberOfTapsRequired:(NSUInteger)numberOfTapsRequired
  66. numberOfTouchesRequired:(NSUInteger)numberOfTouchesRequired
  67. minimumPressDuration:(CFTimeInterval)minimumPressDuration
  68. allowableMovement:(CGFloat)allowableMovement;
  69. -(void)removeLongPressGesture:(NSString*)longPressGestureId;
  70. -(void)removeAllLongPressGestures;
  71. -(void)longPressHandler:(UILongPressGestureRecognizer*)recognizer;
  72. @end