Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView keep the scroll at the correct position while updating NSFetchedResultsController
    text
    copied!<p>I am developing an iOS application that mainly use a <code>UITableView</code>. It retrieves pages of articles from a server. We have got >25000 articles; so I have implemented a pull-to-refresh and infinite scrolling to travel across the title collection. The ones downloaded persist using core data; <code>NSFetchedResultsController</code> is used to automatically update the <code>UITableView</code>. </p> <p>However, I have implemented the infinite scrolling to be in both direction; up and down. Since the user will be allow to scroll down the 25000 article titles, I have to remove the one that the user has already scrolled. If the user scrolls up, I have to re-insert title above the current one. Doing so, I have got a moving window inside the article collection. </p> <p>I display my articles by date group using the section and header. </p> <p>The problem is that because the infinite scrolling goes in both direction, I often delete or add article at a higher position in the table. Infact to achieve that, I have got to change the predicate associated to <code>NSFetchedResultsController</code>. </p> <p>This result by scroll being messed up. I have made it jump back to the position where it was supposed to be ish. It is not nice because it is a jump (animation:NO), if I put the animation ON, it goes all around the place before going back to the right position. And the position is not exactly the one it should be. </p> <p>I am not sure I well explained my problem. I think the problem might be in the way I am using the <code>UITableView</code> but I am not sure how I should use it to make this better.</p> <p>Cheers</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload