我不太了解 tableview 的整体行为:
我有一个带有我在 Storyboard中定义的动态单元格(reuseIdentifier:单元格)的表格 View 。除此之外,我还有两个使用两个 nib 文件创建的自定义 tableviewcell。 单元格当然是这样创建的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
问题是这个单元格是为存在的每个 indexPath 创建的。如何用自定义的 tableviewcell 覆盖在某个 indexPath 处创建的单元格?即使我有一个像下面这样的 if 条件,它被明确编码为返回 customizedCell,返回正常的单元格......这怎么可能?
if (indexPath.row == 4) {
return customizedCell;
}
最佳答案
这就是您拥有 reuseIdentifier
的目的 - 您的自定义单元格应该有它们自己的 reuseIdentifiers
,并且您必须为这些 reuseIdentifiers
出列单元格> 对于您希望在其中包含自定义单元格的行。
关于ios - 如何在使用自定义 UITableViewCell 创建 UITableViewCell 后覆盖它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34135988/