Created
April 7, 2014 07:27
-
-
Save zedzhao/10016072 to your computer and use it in GitHub Desktop.
Determine if touch occurs in subview
This file contains 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
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event{ | |
UIView *subView = [super hitTest:point withEvent:event]; | |
if (UIEventTypeTouches == event.type) { | |
BOOL isOutsideTouch = (subView != self); | |
if(!isOutsideTouch){ | |
for (UIView *s in self.subviews){ | |
if (s == subView) { | |
isOutsideTouch = NO; | |
break; | |
} | |
} | |
} | |
if (isOutsideTouch) { | |
// self.outsideTouchBlock(); | |
NSLog(@"outside touch"); | |
}else{ | |
// self.insideTouchBlock(); | |
NSLog(@"inside touch"); | |
} | |
} | |
return subView; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment