iOS:在 cellForRowAtIndexPath 之外更改 UITableViewCell:

标签 ios uitableview

我正在尝试在我的 UITableView 中实现一个“加载更多”单元格。

如何以编程方式更改单元格“加载更多”的内容、高度等?我假设这可以通过获取选定的单元格来完成,如下所示。例如,当我想更改背景颜色时 - 它没有效果。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if(indexPath.row == 2){
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

}

最佳答案

调用这个函数:

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

像这样的东西:
NSIndexPath* rowToReload = [NSIndexPath indexPathForRow:3 inSection:0];
NSArray* rowsToReload = [NSArray arrayWithObjects:rowToReload, nil];
[UITableView reloadRowsAtIndexPaths:rowsToReload withRowAnimation:UITableViewRowAnimationNone];

更多信息 here .

关于iOS:在 cellForRowAtIndexPath 之外更改 UITableViewCell:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11676925/

相关文章:

objective-c - 对象-c/iOS :About use NSUserDefaults set serial numbers/password

ios - 如何为 collectionView Cell 的 cellForItemAt 中的 subview 着色?

ios - 位置为 :fixed in iOS 11 的闪烁/消失 header

cocoa-touch - UITableView 行高没有用文本绘制得更高

ios - Xcode - iOS8 的搜索栏

ios - 使用 Instruments 追踪内存泄漏 Xcode 5 和 iOS 7

ios - TableView 滚动到最后一个单元格之外

ios - 如何使用 Swift3 使用从 Firestore 集合中检索到的数据填充 TableView

ios - Monotouch/Xamarin 更改 iPad 应用程序的表格行高

ios - UIViewController 连续关闭调用