2012-04-11 188 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。

可能會有效

相關問題