Last active
August 29, 2015 13:58
-
-
Save GregularExpressions/10114517 to your computer and use it in GitHub Desktop.
UICollectionView subclass overriding touches
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
- (void) touchesBegan:(NSSet *)touches | |
withEvent:(UIEvent *)event | |
{ | |
[super touchesBegan:touches withEvent:event]; | |
UITouch* touch = touches.allObjects.firstObject; | |
if ([touch.view isKindOfClass:[SupplementaryViewClass class]]) { | |
SupplementaryViewClass *sectionHeader = (SupplementaryViewClass*)touch.view; | |
[sectionHeader setHighlighted:YES]; | |
} | |
} | |
- (void) touchesEnded:(NSSet *)touches | |
withEvent:(UIEvent *)event | |
{ | |
[super touchesEnded:touches withEvent:event]; | |
UITouch* touch = touches.allObjects.firstObject; | |
if ([touch.view isKindOfClass:[SupplementaryViewClass class]]) { | |
SupplementaryViewClass* sectionHeader = (SupplementaryViewClass*)touch.view; | |
[sectionHeader setHighlighted:NO]; | |
// Tell the Parent View Controller that the supplementary view was tapped as I want to push the nav: | |
if (self.parentViewController && | |
[self.parentViewController respondsToSelector:@selector(didSelectSection:)]) { | |
[self.parentViewController performSelector:@selector(didSelectSection:) withObject:sectionHeader]; | |
} | |
} | |
} | |
- (void) touchesCancelled:(NSSet *)touches | |
withEvent:(UIEvent *)event | |
{ | |
[super touchesCancelled:touches withEvent:event]; | |
UITouch* touch = touches.allObjects.firstObject; | |
if ([touch.view isKindOfClass:[SupplementaryViewClass class]]) { | |
SupplementaryViewClass* sectionHeader = (SupplementaryViewClass*)touch.view; | |
[sectionHeader setHighlighted:NO]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment