Reputation: 2284
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?
Upvotes: 0
Views: 453
Reputation: 33428
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;
}
Upvotes: 1