在UITableView上获取并显示更多记录 [英] Fetching and displaying more records on UITableView
本文介绍了在UITableView上获取并显示更多记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有大约2500条记录要显示.所有这些数据均来自MySQL数据库.类似于iTunes商店,数据将一次在UITableview中显示25.在点击加载更多"时,我需要提取接下来的25条记录.
Hi I have about 2500 records to be displayed. All these data are coming from a MySQL database. The data will be shown 25 at a time in UITableview similar to itunes store. On click of Load More, I need to fetch the next 25 records.
注意:没有仅图像文本.
Note:There is no image only texts.
有人做过类似的事情吗?请给我示例代码.
Have any one done anything similar?Give me the sample code.
推荐答案
first in .h define int row;
and now in viewDidLoad: row=25;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if([your array count]>row)
return row+1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row<row)
{
cell.textLabel.text=@"Your Text";
}
else{
cell.textLabel.text=@"Load More";
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
if (indexPath.row==row)
{
row=row+25;
[tableView reloadData];
}
` 希望对您有帮助.
` hope this will help you..
这篇关于在UITableView上获取并显示更多记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文