在UITableView底部加载更多RSS帖子?
问题描述:
我已经RSS文章加载到一个UITableView,和帖子的数量由这种方法确定:在UITableView底部加载更多RSS帖子?
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (rss.loaded == YES) {
return [rssItems count]*2;
} else {
return 1;
}
}
我怎么能加载更多帖子到tableview中触底之后?
答
您可以在最后一个单元格加载时触发它。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
.
.
.
if (allForecastObjects.count == indexPath.row+1) {
[self getAndAppendMoreData];
}
}
-(void)getAndAppendMoreData {
//this kicks of a preferably asynchronous call for data
//after new data is added to array/collection reload table view
}
-(void)getAndAppendMoreDataCompleted {
if (success) {
[yourTableView reloadData];
}
}
希望这会有所帮助。