2013-05-11 74 views
0

在我的应用程序中,我使用了自定义单元。在它内部,我有许多字段,如按钮,图像,文本框,标签。UITableView自定义单元中的单元重用问题

在那些我需要显示indexpath.sectionindexpath.row

我试着用

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

,但所显示的数值是一段时间不对因重用机制。

如何解决此问题?

+1

你需要证明你的'cellForRowAtIndexPath'方法。还要指定这是全部代码还是使用IB或故事板。 – rmaddy 2013-05-11 17:26:27

回答

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; 
}