UITableView Refresh without scrolling

后端 未结 12 570
时光说笑
时光说笑 2021-02-03 23:06

I have a _TableView with items , and I want to set automatic refresh,and I don\'t want it to scroll on refresh , lets say user scrolled 2 pages down , and the refre

12条回答
  •  逝去的感伤
    2021-02-03 23:31

    Swift 4.2 : Simple Solution

    override func viewDidLoad() {
     super.viewDidLoad()
    
     self.tableView.estimatedRowHeight = 0
     self.tableView.estimatedSectionHeaderHeight = 0
     self.tableView.estimatedSectionFooterHeight = 0
    }
    
    //And then simply update(insert, reloadSections, delete etc) your tableView or reload
    
    tableView.reloadData()
    
    //or
    
    UIView.performWithoutAnimation {
    
      tableView.beginUpdates()
      .....
      tableView.endUpdates()
    }
    

提交回复
热议问题