Skip to content

Hit test not working for cells in a second column + possible fix #209

@VirtualDiveGuide

Description

@VirtualDiveGuide

I couldn't get the following AQGridView function to return YES for cells in the second column of the grid when tapped:

  • (BOOL) _canSelectItemContainingHitView: (UIView *) hitView

I got it working by replacing:

 CGPoint hitCenter = [self convertPoint:[hitView center] fromView:hitView];

for ( AQGridViewCell *aCell in [[self visibleCells] copy])
{

    if ( CGRectContainsPoint( aCell.frame, hitCenter ) )
    return ( YES );

}

with:

UIView *parent = hitView.superview;
while (parent != nil)
{
    if ([parent isKindOfClass:[AQGridViewCell class]])
    {
        return ( YES );
    }
    parent = parent.superview;
}

This could possibly even be a bug with UIView's:

  • (CGPoint)convertPoint:(CGPoint)point fromView:(UIView *)view;

(hitCenter was outside the grid view but debugging the views in the hierarchy suggests this could not be the case.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions