reloadData only on tableView visible cells

前端 未结 3 1820
无人共我
无人共我 2020-12-15 19:53

Is that possible? To reload only the cells that are visible in order to do it more efficient.

相关标签:
3条回答
  • 2020-12-15 20:28

    To reload visible cells of tableview in Swift 3.0:

    guard let visibleRows = pTableView.indexPathsForVisibleRows else { return }
    
    pTableView.beginUpdates()
    
    pTableView.reloadRows(at: visibleRows, with: .none)
    
    pTableView.endUpdates()
    
    0 讨论(0)
  • 2020-12-15 20:31

    Try this, You can reload any cell of the tableview using reloadRowsAtIndexPaths:

    [self.tableView beginUpdates];
    [self.tableView reloadRowsAtIndexPaths:[self.tableView indexPathsForVisibleRows]
                     withRowAnimation:UITableViewRowAnimationNone];
    [self.tableView endUpdates];
    
    0 讨论(0)
  • 2020-12-15 20:45

    That's how table views work by default. The UITableView class never loads cells until they're about to appear onscreen, even when you call reloadData.

    0 讨论(0)
提交回复
热议问题