0

The purpose of this question is not to know when a UITableView is done loading its data (which has been answered in this post) but to know when a UITableView has done drawing all its cells.

Using the visibleCells property inside the

- (UITableViewCell *)tableView:(UITableView *)iTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

method doesn't work because when the tableview is loaded for the first time, no cells are visible yet.

The idea is to animate the cell appearance when the tableview is refreshed.

This seems like a complex task to perform but I'm surprised Apple didn't provide any delegate method to use when a tableview is done loading.

Community
  • 1
  • 1
apouche
  • 9,703
  • 6
  • 40
  • 45

2 Answers2

0

Better try this method, pass NSArray of indexPaths that you want to reload with given set of animation

- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation  

Hope it works

Monolo
  • 18,205
  • 17
  • 69
  • 103
Allamaprabhu
  • 845
  • 1
  • 7
  • 17
0

I don't believe there is a method that indicates when a table has loaded it's cells. However, you can achieve your goal of animating in the table cell whenever it is drawn.

Logic:

  1. UITableView displays UITableViewCells as needed.
  2. Each UITableViewCell is a subclass of UIView.
  3. UIView has drawRect, which is called every time the view is drawn.
  4. So, put your animation in UITableViewCell's drawRect method & it'll animated whenever it's drawn.

Implementation:

  1. Create a subclass of UITableViewCell,
  2. Apply this subclass to your table cells,
  3. Add the drawRect method, and
  4. Implement your animation in the drawRect method.

I have done this in one of my projects and it worked great. It draws the animation when the table is loaded or scrolled and when the display is rotated. With this approach you don't need to know when the table is done loading – each cell is simply animated whenever it is drawn.

One final note – if you put another view controller on top of your table view and then dismiss it, you may need to reload the table and set each UITableViewCell to setNeedsDisplay. This will force drawRect to be called again for each UITableViewCell.

nurider
  • 1,555
  • 1
  • 18
  • 21