Delegate method willSelectItemAtIndex can't skip item selection + additional issues #127

Open
ghost opened this Issue Apr 20, 2012 · 2 comments

Projects

None yet

1 participant

@ghost
ghost commented Apr 20, 2012

There is no way to skip cell selection (and also deselection of previously selected cell).

  1. The message [delegate willSelectItemAtIndex:] is called after cell deselection and no return value can't skip calling [delegate didSelectItemAtIndex:]

  2. It isn't possible to use gridView.indexOfSelectedItem in [delegate willSelectItemAtIndex:], value is NSNotFound in every cases (it causes premature deselection).

  3. Delegate methods willSelect+didSelect are called even if user tapped to grid view but out of any cell (index value is NSNotFound in this case).

@evadne
Collaborator
evadne commented Apr 20, 2012

Would you like to elaborate your use case so we can figure out a way
around this or a fix?

On Apr 20, 2012, at 23:06, c4tto
reply@reply.github.com
wrote:

There is no way to skip cell selection (and also deselection of previously selected cell).

  1. The message [delegate willSelectItemAtIndex:] is called after cell deselection and no return value can't skip calling [delegate didSelectItemAtIndex:]

  2. It isn't possible to use gridView.indexOfSelectedItem in [delegate willSelectItemAtIndex:], value is NSNotFound in every cases (it causes premature deselection).

  3. Delegate methods willSelect+didSelect are called even if user tapped to grid view but out of any cell (index value is NSNotFound in this case).


Reply to this email directly or view it on GitHub:
#127

@ghost
ghost commented Apr 20, 2012

I suppose that the behavior of AQGridView should be very similar to UITableView.

  1. There is possibility in UITableView to skip selection in delegate method willSelectRowAtIndexPath. Usual return value is new indexPath in this method, but you can refuse selection change by returning nil. I thought I can also refuse selection in AQGridView by using value NSNotFound, but it doesn't work.

  2. I want to check before cell selection if some other cell is already selected. Unlike UITableView I can't do it, because deselection is performed too early. The value of gridView.indexOfSelectedItem is always NSNotFound willSelectRowAtIndexPath.

  3. I have a grid view which isn't full and there is some free space under cells. If user tap to that space, both methods willSelect+didSelect are called and index value is NSNotFound. I think that methods shouldn't be called.

@ghost Unknown pushed a commit to ondrejstocek/AQGridView that referenced this issue Apr 23, 2012
@ondrejstocek ondrejstocek Issue #127 - The behavior of [delegate willSelectItemAtIndex:] is mor…
…e similar to UITableView.

1) selection change can be refused in method by returning value NSNotFound.
2) deselection of previous selected item is made after calling willSelectItemAtIndex method, so it is possible to use gridView.indexOfSelectedItem
3) Grid view which isn't full and there is some free space under cells. If user tap to that space, both methods willSelect+didSelect are called and index value is NSNotFound. Fixed, methods aren't no more called.
2a39209
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment