Reload tableview section without scroll or animation

后端 未结 8 1179
轻奢々
轻奢々 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:25

    Neither of given answers worked for me. Here's the solution I found, hope it would be useful to someone

    Swift 4:

    let lastScrollOffset = tableView.contentOffset
    
    tableView.beginUpdates()
    tableView.reloadSections(IndexSet(integer: 1), with: .none)
    tableView.endUpdates()
    
    tableView.layer.removeAllAnimations()
    tableView.setContentOffset(lastScrollOffset, animated: false)
    

提交回复
热议问题