2013-05-11 54 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; 
}