在 iOS 中重新加载特定的 UITableView 单元格 [英] Reload specific UITableView cell in iOS

查看:25
本文介绍了在 iOS 中重新加载特定的 UITableView 单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UITableView.我想根据所做的选择更新表数据.现在我使用 [mytable reloadData];我想知道是否有任何方法可以更新所选的特定单元格.我可以使用 NSIndexPath 或其他方式进行修改吗?有什么建议吗?

I have a UITableView. I want to update the table data based on selection made. Right now I use [mytable reloadData]; I want to know if there is any way where I can just update the particular cell which is selected. Can I modify by using NSIndexPath or others? Any suggestions?

谢谢.

推荐答案

对于 iOS 3.0 及以上,你只需要调用:

For iOS 3.0 and above, you just have to call :

- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;

例如,要重新加载第 2 节的第 3 行和第 3 节的第 4 行,您必须这样做:

To reload row 3 of section 2 and row 4 of section 3 for example, you'll have to do this :

// Build the two index paths
NSIndexPath* indexPath1 = [NSIndexPath indexPathForRow:3 inSection:2];
NSIndexPath* indexPath2 = [NSIndexPath indexPathForRow:4 inSection:3];
// Add them in an index path array
NSArray* indexArray = [NSArray arrayWithObjects:indexPath1, indexPath2, nil];
// Launch reload for the two index path
[self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];

这篇关于在 iOS 中重新加载特定的 UITableView 单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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