是否可以刷新UITableView中的单个UITableViewCell? [英] Is it possible to refresh a single UITableViewCell in a UITableView?

查看:406
本文介绍了是否可以刷新UITableView中的单个UITableViewCell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用UITableViewCell的自定义UITableView. 每个UITableViewCell具有2个按钮.单击这些按钮将更改单元格中UIImageView中的图像.

I have a custom UITableView using UITableViewCells. Each UITableViewCell has 2 buttons. Clicking these buttons will change an image in a UIImageView within the cell.

是否可以分别刷新每个单元以显示新图像? 感谢您的帮助.

Is it possible to refresh each cell separately to display the new image? Any help is appreciated.

推荐答案

有了单元格的indexPath后,您可以执行以下操作:

Once you have the indexPath of your cell, you can do something like:

[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPathOfYourCell, nil] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates]; 

在Xcode 4.6和更高版本中:

In Xcode 4.6 and higher:

[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:@[indexPathOfYourCell] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates]; 

您当然可以设置任何喜欢的动画效果.

You can set whatever your like as animation effect, of course.

这篇关于是否可以刷新UITableView中的单个UITableViewCell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆