Created
December 5, 2012 05:02
-
-
Save kaiix/4212431 to your computer and use it in GitHub Desktop.
UIImageView+Touch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @interface UIImageView (Touch) | |
| @property(nonatomic, assign) id delegate; | |
| @end | |
| @protocol UIImageViewTouchDelegate <NSObject> | |
| @optional | |
| - (void)imageViewDidTouch:(UIImageView *)imageView withPoint:(CGPoint)point; | |
| @end | |
| @implementation UIImageView (Touch) | |
| static char kUIImageViewTouchDelegateKey; | |
| - (void)setDelegate:(id)delegate { | |
| objc_setAssociatedObject(self, &kUIImageViewTouchDelegateKey, delegate, OBJC_ASSOCIATION_ASSIGN); | |
| } | |
| - (id)delegate { | |
| return objc_getAssociatedObject(self, &kUIImageViewTouchDelegateKey); | |
| } | |
| - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { | |
| BOOL result = [super pointInside:point withEvent:event]; | |
| if ([self.delegate respondsToSelector:@selector(imageViewDidTouch:withPoint:)]) { | |
| [self.delegate imageViewDidTouch:self withPoint:point]; | |
| } | |
| return result; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment