UITableView Refresh without scrolling

后端 未结 12 597
时光说笑
时光说笑 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:37

    SWIFT 3

    let contentOffset = self.tableView.contentOffset
    self.tableView.reloadData()
    self.tableView.layoutIfNeeded()
    self.tableView.setContentOffset(contentOffset, animated: false)
    

    This is error of iOS8 when using UITableViewAutomatic Dimension. We need store the content offset of table, reload table, force layout and set contenOffset back.

    CGPoint contentOffset = self.tableView.contentOffset;
    [self.tableView reloadData];
    [self.tableView layoutIfNeeded];
    [self.tableView setContentOffset:contentOffset];
    

提交回复
热议问题