funct7
funct7

Reputation: 3601

iOS Table view cell not displaying properly after resize

I have set up my table view with 6 static cells and I'm trying to have one cell (the third cell) expand upon selection. The problem is, it resizes after calling reloadRowsAtIndexPaths:, but then the cell appears blank. If I scroll the cell out of view, it shows the contents properly.

When I call [tableView reloadData] the cell isn't blank, but then, I can't enjoy the animation.

Does anyone know why this is so?

Upvotes: 1

Views: 225

Answers (3)

funct7
funct7

Reputation: 3601

I don't know if I was the only one having the problem with a blank static cell issue. I stumbled on a solution and that is calling [tableView reloadData] after calling reloadRowsAtIndexPaths:

Upvotes: 1

Jayaprada
Jayaprada

Reputation: 954

  • Reload the respective table view row using the main thread.

[[NSOperationQueue mainQueue] addOperationWithBlock:^{

    // Reload the respective table view row using the main thread.
    [self.tblFiles reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:index inSection:0]]
                         withRowAnimation:UITableViewRowAnimationNone];
    
}];

Upvotes: 0

Rick
Rick

Reputation: 196

Well if you set the height for a row then you need to reload the content of the cell NOT the content of the whole table. If you call [tableview reloadData] then it simply means that you redraw the whole table(without the height correction).

To reload a single cell in the table:

[tableView beginUpdates];
[tableView reloadRowsAtIndexPaths:indexPath] withRowAnimation:UITableViewRowAnimationNone];
[tableView endUpdates]; 

Upvotes: 1

Related Questions