Error: UITableView jump to top with UITableViewAutomaticDimension

前端 未结 7 1740
半阙折子戏
半阙折子戏 2020-12-05 15:17

I am using UITableView with estimatedRowHeight and UITableViewAutomaticDimension. Also I am using NSFetchedResultsControllerDele

7条回答
  •  被撕碎了的回忆
    2020-12-05 15:39

    Adding to @jayesh-miruliya 's answer, in your NSFetchedResultsControllerDelegate after the switch statement, put this in your code:

    tableView.reloadData()
    dispatch_async(dispatch_get_main_queue(), {
        let topCellIndexPath = NSIndexPath(forRow: 0, inSection: 0)
        self. tableView.scrollToRowAtIndexPath(topCellIndexPath, atScrollPosition: .Top, animated: true)
    })
    

提交回复
热议问题