views:

53

answers:

1

I'm trying to create a tableview which contains different types of table cell but I'm stuck. How do I return a different type of cell dependent on the row number in the...

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

function.

+3  A: 

All you gotta do is switch on the row or section of your nsindexpath and return the appropriate UITableView cell...lets say u have TableViewCellA and TableViewCellB one for row 0 and other for row 1

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
     UITableViewCell *cell;
    if(indexPath.row==0)
   {
     cell=..//tableviewcellA 
   }
   if(indexPath.row==1)
    cel=///tableviewcell b 
}

and so forth, hope this helps

Daniel
Thanks. I've been going down cul-de-sacs for a day and this was the solution all along. Thanks.
Matt