开发者

Fetching and displaying more records on UITableView

开发者 https://www.devze.com 2023-04-03 14:26 出处:网络
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

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 on开发者_JS百科ly 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..

0

精彩评论

暂无评论...
验证码 换一张
取 消