Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

making a "load more" button in uitableviewcell?

hey, Could any one guide me through this I have around 15 entries in table I would like another 15 to come up with the load more in last UITableViewCell. could anyone help me?

like image 313
Tushar Chutani Avatar asked May 28 '11 05:05

Tushar Chutani


2 Answers

to show an extra row in the tableview, in

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return dataRows+1;
    }

In

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

        //after setting tableviewcell

        if(indexPath.row==dataRows){

        cell.textLabel.text=@"Load More Rows";
        }
    }

In

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {

    if(indexPath.row==dataRows){
    //there you can write code to get next rows
    }
 }

You need to update the numberOfRows variable according to the displayed rows.

Edit: After fetching the extra entries, you can add them to the existing entries array using the following method. Your original array should be a NSMutableArray to use this method.

[originalEntriesArray addObjectsFromArray:extraEntriesArray];

like image 106
SriPriya Avatar answered Oct 15 '22 03:10

SriPriya


I wrote an example project that does just this. Download it from GitHub https://github.com/Abizern/PartialTable

like image 8
Abizern Avatar answered Oct 15 '22 04:10

Abizern