0

我有自定义 UITableView 和 UIImageView,UILabel 在里面。在某些通知上,我只需要更新 UILabel 而不是 UIImageView。如果我这样做:

[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:idxCell inSection:0]] withRowAnimation:UITableViewRowAnimationFade];

单元格的所有内容都在更新,我对 UIImageView 有闪烁效果。我已经这样做了:

MyTableViewCell *cell = (MyTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:idx inSection:0]];
cell.counterLabel.text = [NSString stringWithFormat:@"%@", counter];

但是我觉得不好,因为它不对应MVC模式。我想我应该更新我的模型对象。我需要建议,我该怎么做?

4

1 回答 1

0

您应该从您获取数据的地方更新您的 NSArray 或 NSDictionary。因为当您重新加载行时,它再次调用相同的字典或数组并且具有相同的值。

didSelectRowAtIndexPath 在更新字典或数组,然后重新加载行。

cellForRowAtIndexPath 更新获取行数据的 NSArray 或 NSDictionary。

可能有效

于 2012-04-11T04:52:36.947 回答