2012-04-11 100 views
0

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

[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模式。我想我应该更新我的模型对象。我需要建议,我该如何做到这一点?

回答

0

你应该从哪里取数据来更新你的NSArray或NSDictionary。因为当你重载行时,它会再次调用相同的字典或数组,并且具有相同的值。

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

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

可能会有效

相关问题