Reload tableview section without scroll or animation

后端 未结 8 1166
轻奢々
轻奢々 2020-12-08 07:03

I am reloading a tableView section using this code -

self.tableView.beginUpdates()
self.tableView.reloadSections(NSIndexSet(index: 1), withRowAnimation: UITa         


        
8条回答
  •  無奈伤痛
    2020-12-08 07:43

    I've had this problem too. It seems to stem from putting an IndexPath inside .reloadSections instead of a IndexSet as it requests. Which is why it seems to work with .reloadRows with out issue:

    tableView.reloadRows(at: [IndexPath], with: UITableView.RowAnimation)
    
    tableView.reloadSections(IndexSet, with: UITableView.RowAnimation)
    

    Just wrap the section you want to reload as an IndexSet:

    tableView.reloadSections(IndexSet(integer: sectionInt), with: .none)
    

提交回复
热议问题