How to prevent from scrolling UITableView up when NSFetchedResultsController add new record?

前端 未结 2 1111
清酒与你
清酒与你 2020-12-19 14:23

My UITableView is scrolling up once I add a new comment to CoreData. NSFetchedResultsController knows about it, puts this comment at the bottom of the table, an

2条回答
  •  醉梦人生
    2020-12-19 14:36

    I found something that worked for me. I encountered the same problem, and my estimatedRowHeight was 33 and all of my cells are greater than 33.

    I just changed my estimatedRowHeight to my maximum cell height(or greater than your maximum cell height)

        self.table.estimatedRowHeight = 310
        self.table.rowHeight = UITableViewAutomaticDimension
    

    worked like a charm, all cells are now autoresizing and uitableview is not scrolling to top or bottom when core data performs an update/delete/insert

提交回复
热议问题