Ho can I tell when the background is touched on a UICollectionView?

Posted by Mason Cloud on Stack Overflow See other posts from Stack Overflow or by Mason Cloud
Published on 2013-11-03T09:51:07Z Indexed on 2013/11/03 9:53 UTC
Read the original article Hit count: 995

Filed under:
|

I've tried subclassing UICollectionView and overriding touchesBegan:withEvent: and hitTest:WithEvent:, and both of those methods trigger when I touch a cell. However, if I touch the space between the cells, nothing happens at all. Here's what I've created:

@interface WSImageGalleryCollectionView : UICollectionView
@end

..and..

@implementation WSImageGalleryCollectionView

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"Touches began");
    [super touchesBegan:touches withEvent:event];
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    NSLog(@"Hit test reached");
    return [super hitTest:point withEvent:event];
}

@end

© Stack Overflow or respective owner

Related posts about ios

Related posts about uicollectionview