0

How can I get informed when UICollectionViewCell is about to be scroll out from superview (will be queued)? I need to resignFirstResponder from that cell before the cell is queued.

Povilas
  • 445
  • 3
  • 17
  • Not related to Xcode. As to the question, you could implement the [`willMoveToSuperview:` method](http://stackoverflow.com/questions/8282288/is-willmovetosuperview-called-with-nil-when-removing-a-view-from-a-hierarchy). –  Jul 19 '13 at 14:36
  • overriding dealloc to send a notification should work... but hopefully someone else has a better idea. – Abhi Beckert Jul 19 '13 at 14:37
  • What do you mean by "move out"? Scroll out of view, or removing the cell completely? – Mike D Jul 19 '13 at 14:37
  • Dequeuing means "take out of the queue and put on screen". Queuing means "remove from screen and put in the queue", so you really mean "queuing"? – Scott Berrevoets Jul 19 '13 at 14:39
  • you're right, I corrected the question – Povilas Jul 19 '13 at 14:43
  • In that case you're going to have to monitor scroll events and then check for the visible rect whenever it changes. Note that recent versions of iOS and OS X will render scroll view contents that is *not currently visible* in order to improve scrolling performance (basically the pixels are already rendered and in the GPU when the user starts scrolling). Make sure your code is fast... perhaps offload it to a background thread. – Abhi Beckert Jul 19 '13 at 14:46

1 Answers1

2

On the delegation method of UICollectionViewDelegate:

- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
Rui Peres
  • 25,741
  • 9
  • 87
  • 137