在我的应用程序中,我使用了自定义单元格。在其中我有许多字段,如按钮,图像,文本字段,标签。
其中我需要显示indexpath.section
和indexpath.row
值
我试过
cell.sectionLabel.text = [NSString stringWithFormat:@"%d", indexPath.section];
cell.rowLabel.text = [NSString stringWithFormat:@"%d", indexPath.section];
但由于重用机制,显示的值有些时间错误。
如何解决此问题?
答案 0 :(得分:1)
也许你可以分享其他一些代码。
与此同时(这是传统方式)
- (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;
}