4

While using collection view, in cellforItemAtIndexPath, new cell instance is being added multiple times (on top of another) at same location/frame, even though correct reuseidentifier is being passed to "dequeueReusableCellWithReuseIdentifier:forIndexPath:"

The cell mentioned above is a subclass of UICollectionViewCell and contains UITextField with proper frame. When scrolling and textfield is first responder, the above said problem is occurring.

Please let me know of any pointers to address the issue.

aditya
  • 111
  • 1
  • 1
  • 7
  • can you show a piece of code? – heximal Jan 09 '13 at 10:12
  • please look the code at url http://pastebin.com/dMBaJkbT – aditya Jan 09 '13 at 12:28
  • please look at http://pastebin.com/t3YRGZXu. Two cells are being added at frame (110 70; 100 70) – aditya Jan 09 '13 at 12:44
  • Have you rolled your own UICollectionViewLayout ? – TheBasicMind Jan 27 '13 at 10:22
  • I'm seeing similar behaviour with collection view cells that contain a UIWebView. I'm using paging and each cell fills the bounds (so I only have one cell visible at once). When I'm scrolling back and forth, I see sensible behaviour - two cells are being recycled in turn to provide the new cell that scrolls into view. – Geoff Hackworth Jul 08 '13 at 11:35
  • But, if I long tap on a web view in a cell to bring up the Copy menu it seems to trigger weird behaviour where that cell will not be removed from the view hierarchy when I scroll. I can end up with many cells in the view, sometimes on top of each other. – Geoff Hackworth Jul 08 '13 at 11:42
  • Please have a look http://stackoverflow.com/questions/16898584/collection-view-with-custom-layouts-cells-misbehave-on-scrolling/16936573#16936573 – Shivam Mishra Dec 24 '13 at 11:41

1 Answers1

2

This could be a bug in UICollectionView related to one I've already filed with decoration views. As long as your cells are opaque, it should not affect your interface

It's possible (though, imo, not very likely) that this is correct behaviour for UICollectionView and it uses those extra cells for interface orientation. At any rate, the problem seems much less pronounced that the one with decoration views, which would add dozens of copies of the decoration view. As long as it's not affecting your app, I'd say live with it.

Ash Furrow
  • 12,391
  • 3
  • 57
  • 92