Objective C, How to load more data when user tries to scroll up at the bottom row of the tableview
I have UITableView and I want to load more data when user tries to scroll up at the bottom row of the tableview just like iPhon开发者_开发知识库e email application...What is the best way for this?
Implement the Delegate for UIScrollView and detect at which point where you want to load more data. Or You can put the update code in the "cellForRowAtIndexPath:" method, here detect the row, say 100 and append the data, and remove the data in row <100 , you will have to check for dataSource's count before updating.
Append new contents to the Data Source (Array) and do this:
[self.tableView reloadData];
I tried adding this in UITableViewDelegate method "willDisplayCell"
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if(indexPath.row == floatRows - 1) { floatRows += 10; [tableView reloadData]; } }
It is keep loading another 10 for every scroll to bottom. Not sure, it will work for you.
精彩评论