Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView load cells reverse

I want to make my cell load and use it's data in reverse. Basically, I want the last cell to be the first.

like image 207
Jab Avatar asked May 11 '10 02:05

Jab


People also ask

How can we use a reusable cell in Uitableview?

For performance reasons, a table view's data source should generally reuse UITableViewCell objects when it assigns cells to rows in its tableView(_:cellForRowAt:) method. A table view maintains a queue or list of UITableViewCell objects that the data source has marked for reuse.

How do I delete a cell in Uitableview?

So, to remove a cell from a table view you first remove it from your data source, then you call deleteRows(at:) on your table view, providing it with an array of index paths that should be zapped. You can create index paths yourself, you just need a section and row number.


1 Answers

Do you mean you want to display your data from rail to head? Maybe you should perform it at your table's data source method:

- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  ...
  NSUInteger row = [indexPath row];
  NSUInteger count = [listData count]; // here listData is your data source
  cell.textLabel.text = [listData objectAtIndex:(count-row-1)];
  return cell;
}
like image 198
Elliot Chen Avatar answered Oct 02 '22 08:10

Elliot Chen