Skip to content

Instantly share code, notes, and snippets.

@clooth
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clooth/b6e9290fb944d1f5a3f6 to your computer and use it in GitHub Desktop.
Save clooth/b6e9290fb944d1f5a3f6 to your computer and use it in GitHub Desktop.
// Splitter view recognizer should only begin if we're truly touching something inside the splitter view
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer == _splitterPanRecognizer) {
CGPoint location = [gestureRecognizer locationInView:self.view];
BOOL didHitView = NO;
NSArray *hitTestViews = @[_splitterView];
hitTestViews = [hitTestViews arrayByAddingObjectsFromArray:_splitterView.subviews];
for (UIView *hitTestView in hitTestViews) {
CGPoint locationInView = [hitTestView convertPoint:location fromView:self.view];
if (CGRectContainsPoint(hitTestView.bounds, locationInView)) {
didHitView = YES;
}
}
return didHitView;
}
return NO;
}
// Make other gesture recognizers fail if we have a hit on our splitter view
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
if ([self gestureRecognizerShouldBegin:gestureRecognizer] == YES) {
return YES;
}
return NO;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment