Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView reloadRowsAtIndexPaths hides row

I use UITableView with static cells. If I use reloadData, than everything is OK.

If I try reloadRowsAtIndexPaths it hides row. Row appears if I drag tableView up-down(when cell is updated).

like image 504
Shmidt Avatar asked Jul 30 '12 16:07

Shmidt


3 Answers

If your table cells are static (i.e., you are using the same cell object to replace the one that's currently displayed), what you're seeing is an artifact of the transition animation.

Think of it this way. Lets say you set UITableViewAnimationOptionFade. When the cell is to be replaced, the cell it's to be replaced with (which in this case is the exact same object) has a fade-in animation added to it. Then, the cell that is being replaced (again, it's all the same object) has a fade-out animation added to it. At the end, the cell is actually there, but it's invisible because the fade-out animation has made that cell object invisible.

In a non-static tableview, one in which the replacement cell is a different object than the cell to be replaced, this isn't a problem, as the animations are added to two different objects.

like image 121
leftspin Avatar answered Feb 22 '23 19:02

leftspin


I had the same problem, it seems to be a bug. I experimented some and the problem doesn't occur when I set the animation option to UITableViewRowAnimationNone. Some other interesting stuff happens when you set that option to UITableViewRowAnimationTop, too.

like image 26
Scott Berrevoets Avatar answered Feb 22 '23 20:02

Scott Berrevoets


I solved this by removing animation

tableView.reloadRows(at: [yourIndexPath], with: UITableView.RowAnimation.none)

Hope this helps to anyone searching for this.

like image 31
Ilya Shevyryaev Avatar answered Feb 22 '23 19:02

Ilya Shevyryaev