5

If I keep a fixed UITableViewCell with reuseidentifier=nil as an ivar and return this instance for a specific row, and then reload this row specifically using [tableView reloadRowsAtIndexPaths:withRowAnimation:], the row contents disappear (or sometimes flicker). When I scroll away and back, it becomes visible again. If I do [tableView reloadData] on the other hand, it will not disappear.

  • Why does it disappear, when I reload the row ?
  • Why doesn't it, when I reload the whole table ?

Here is a sample project: https://github.com/hannesoid/HOTableViewTests

I tested this on iOS 6. I know that manually reusing a UITableViewCell in such a way (with out reuseidentifier & dequeueing) is not typically recommended, but in some quite static scenarios it would simplify things.

Hannes
  • 51
  • 3

2 Answers2

1

UITableView is optimized by Apple so that it uses a reasonably small amount of memory and yet still has good performance for when cells appear on the screen. When you do something non-standard like this, and circumvent the optimization, you throw the whole machine out of whack. Here's what I suggest. If you have one specific row that you're now holding as an instance variable, why not simply try giving it a unique name for its reuseIdentifier? Let the kit work it out.

Mario
  • 2,397
  • 2
  • 24
  • 41
0

It's not a good practice to make reuseIdentifier equal to nil. Always initialize reuseIdentifier with a string/name. The cellForRowAtIndexPath reloads rows by looking to their reuseIdentifiers. If cached cells are founds with an existing reuseIdentifier, it displays those cells directly without allocating and initializing new one. Making it nil causes problem. So, make reuseidentifier=@"cell" or something you like. This will solve your problem.

Muhammad Ibrahim
  • 1,923
  • 2
  • 15
  • 13