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

查看:23
本文介绍了是否可以刷新 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天全站免登陆