2013-03-14 66 views
0

我似乎在嘗試訪問特定單元格時遇到了一些困難,我只需要在TableView中選擇它時更改其中的一個對象。必須有一種更有效的方式,而不僅僅是重新調用reloadData。因爲這是我可以使表格單元格看起來不同的唯一方法,通過在選擇其中一個時重建它。感謝所有的幫助:)如何選擇單元格對象如何選擇

[self updatePreferences]; 
[tableView reloadData]; 

這是我所有的atm方法,它處理表格單元格的交互。

+0

您可以撥打tableView.reloadRowsAtIndexPaths 見http://stackoverflow.com/questions/4448321/is-it-possible-to-refresh-a-single-uitableviewcell-in-a-uitableview – 2013-03-14 19:35:36

回答

0

使用以下代碼。重新加載單個單元格。

NSArray *array = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:row inSection:section]]; 
[self.tableView reloadRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationNone]; 
0

您也可以使單元格爲自定義單元格,併爲其添加一個方法,如更新或刷新。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    CustomCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
    [cell refresh]; 
}