2013-03-14 51 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]; 
}