0

In my my app I have used a custom cell. Within it I have many fields like button, image, textfield, label.

Among those I need to display the indexpath.section and indexpath.row values

I tried with

cell.sectionLabel.text = [NSString stringWithFormat:@"%d", indexPath.section];    
cell.rowLabel.text = [NSString stringWithFormat:@"%d", indexPath.section];

but the displayed values are some time wrong due to reuse mechanism.

How to resolve this issue?

Lorenzo B
  • 33,216
  • 24
  • 116
  • 190
iOS dev
  • 2,254
  • 6
  • 33
  • 56
  • 1
    You need to show your `cellForRowAtIndexPath` method. Also specify whether this is all in code or you are using IB or storyboards. – rmaddy May 11 '13 at 17:26

1 Answers1

1

Maybe you can share some other code.

In the meantime (that's the traditional way)

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

    //dequeue the cell here...

    if(!cell) {
        //create the cell here...
    }

    cell.sectionLabel.text = [NSString stringWithFormat:@"%d", indexPath.section];
    cell.rowLabel.text = [NSString stringWithFormat:@"%d", indexPath.row]; // set row here

    return cell;
}
Lorenzo B
  • 33,216
  • 24
  • 116
  • 190