Scrolling to load more cells in UITableView like Amazon app

我与影子孤独终老i 提交于 2019-12-18 13:42:26

问题


I am trying to create a UITableView where more rows loads automatically as I scroll to the bottom of the list. This is typically like the search function on the Amazon app for iPhone. It loads about 20 rows at a time and when I scroll to the end of the first 20, then the next 20 automatically load up. Once loaded, it remains in memory. I am not considering an option where the last row says "Load more items" like in the App store app.

Here is what I am trying to achieve: My current app thread takes about 8-15 seconds to load the UITableView (anywhere from 0-50 items in list). It takes about 8 seconds even if there is just 1 row. I would like to make this process appear faster. My screen can display a max of 7 rows at any given time, so I am thinking if I can make this load 8-10 rows at a time and be able to achieve this in, let's say, 3-4 seconds, then the other items can load as the user scrolls all the way down. So, the first time loading of the table will appear to be twice as fast as it is now.

I have been looking at "Pull to Refresh" like the Tweetie2 app and am also looking at Three20 code on github, but am not too sure how to get this implemented like the Amazon app.

The primary focus is on how to make it load faster and without additional user input.

Any help would be greatly appreciated.


回答1:


Have you consider using the UITableViewDelegate method:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

If you keep knowledge of the index of the last cell you have loaded and if you get close to scrolling to that cell, to start asynchronous requests to load more rows.



来源:https://stackoverflow.com/questions/4610299/scrolling-to-load-more-cells-in-uitableview-like-amazon-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!