Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TableView sections become hidden after reloadSections

My question is the following: there is a table consisting of headers. When you click on the header, it restarts after

[self.tableView reloadSections: [NSIndexSet indexSetWithIndex: section] withRowAnimation: UITableViewRowAnimationAutomatic];

Actually, in the earlier version (iOS 6.1.3 and lower), cell reloaded and everything is fine. On the iOS7 cells become hidden. What is it and how to solve it? And not only cell that is clicked, but the next standing(lower or above).

<MyHeaderCell: 0x146ea600; baseClass = UITableViewCell; frame = (0 0, 320 75); hidden = YES; autoresize = W; gestureRecognizers = <NSArray: 0x146e10c0>; layer = <CALayer: 0x146e95d0 »

Basically, it is one of those issues in the logs. It is clearly seen that cells become hidden.

Nevertheless, when I use [self.tableView reloadData]; everything is fine, but I need animation.

like image 265
Nikolay Avatar asked Sep 27 '13 15:09

Nikolay


2 Answers

this is an old question, but I think I know what's causing this.

Is this a "static" cell in the sense that you're keeping a reference to it yourself? In that case, the problem is probably this:

When you do an animated reload, the table view will fade out existing cells while at the same time fading in the new cells. The problem is that when the "new" cell is the exact same cell as the old one, the same cell will both fade in and fade out at the same time! And in your case, the fade out animation takes precedence and the cell is hidden.

This if fixed by always reusing cells instead of using the same reference, however, I know that this is not always optimal.

like image 110
Accatyyc Avatar answered Sep 28 '22 10:09

Accatyyc


Calling [tableView reloadData] right after [tableView reloadSections:withRowAnimation] fixes it without significantly affecting the animation.

like image 42
Kalyan02 Avatar answered Sep 28 '22 09:09

Kalyan02