nsscreencast / comments

Public comments on NSScreencast.com
0 stars 0 forks source link

Automatic UITableView Paging Автоматический пейджинг UITableView #161

Open subdigital opened 3 years ago

subdigital commented 3 years ago

Written on 11/23/2017 11:31:42

URL: https://nsscreencast.com/episodes/309-automatic-uitableview-paging

subdigital commented 3 years ago

originally written by Tim Trautmann on 11/14/2017 21:54:26

Have you considered using UITableViewDataSourcePrefetching for this exercise?

subdigital commented 3 years ago

originally written by subdigital on 11/14/2017 22:02:18

Yes, I got this question from a couple of others, so it's probably worth a quick follow-up episode that covers that protocol!

subdigital commented 3 years ago

originally written by Tim Brooks on 11/21/2017 00:07:33

Very nice. I implemented something just like this recently in my main app. One small variation that I use is to trigger the fetch sooner. That is, I don't wait until the user hits the last row to trigger the next fetch. Instead, also using willDisplay, i check to see whether their current scroll position is 1/2 way thru the prior last row + 1/2 of the last batch size. Basically, each time they've scrolled 1/2 thru the last batch size I kick off the next fetch. If your endpoint is fast enough, and the stars are aligned, you can often fetch the next set before the user even knows they've hit the end. One other nuance is that I also track their scrolling direction - and don't kick off the fetch unless they're still scrolling 'down'.

subdigital commented 3 years ago

originally written by bradley on 05/18/2018 20:12:51

Great, Thanks, i'm using mvvm but it works well with the same pattern, one very importan thing `self.shouldShowLoadingCell = page.currentPage < page.numberOfPages` should go always before tableView.realoadData(), if not it doesn't work.