0

In table view, I am adding new cells (to the top of table view) with animation (background color of cells changing from gray to default white). All works fine, but it animates only cells, that is visible on the screen. So, if count of rows more that display can show, it doesn't animate the rest of cells.

This is my code for animating cells (I use it in my custom update table view method, after insertion of new rows. InsertingArray consists of IndexPath's of rows that should be animated):

for (int i=0; i<[insertingArray count]; i++)
{
    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[insertingArray objectAtIndex:i]];
    cell.backgroundColor = [UIColor grayColor];
    [UIView animateWithDuration:1.0
            delay: 1.0
            options: UIViewAnimationOptionCurveEaseIn
            animations:^{
            cell.backgroundColor = [UIColor whiteColor];
    }
    completion:nil];
}

So, how fix it and animate all rows, that was added in table view?

Troir1
  • 63
  • 3
  • 9
  • Maybe it would be better to animate background of whole table view instead? – Azat May 09 '15 at 18:03
  • I had a similar issue, and moved my cell animation code (which slid labels the the right and added a tick box) into -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath – Gismay May 09 '15 at 18:10
  • The thing is, besides of inserting rows to the top, I have a method of downloading old rows (notifications) from database (while scrolling down), so if I will play animation in willDisplayCell method it will animate all new cells in table view. I need to animate only that was added to the top. – Troir1 May 09 '15 at 18:16
  • 1
    `it doesn't animate the rest of cells` - that statement demonstrates pretty clearly that you do not know how iOS handles the reusable cells internally - most of the time there are not cells off screen. there is content that would be displayed off screen but that is not associated with a ui cell -> http://stackoverflow.com/questions/2152180/iphone-what-are-reuseidentifiers-uitableviewcell – luk2302 May 09 '15 at 22:20

0 Answers0