gpt4 book ai didi

ios - 重用后如何使自定义 UITableViewCell 顶部单元格唯一绘制?

转载 作者:行者123 更新时间:2023-11-28 22:16:48 25 4
gpt4 key购买 nike

所以我制作了一些自定义表格 View 单元格,它们可以正确绘制并且看起来很棒,但是一旦我滚动到可见单元格的边缘,它们就会开始被重复使用,这很好,除了当我向后滚动重复使用的单元格时仍然显示并且不重绘。具体来说,除了最顶部的单元格外,所有单元格看起来都一样。

详细描述事件的图片:

desired then scroll down then scroll up and the issue

我是如何编码的,如果 indexPath.row 大于 0,则在创建单元格时添加“重叠效果”,这只是放置在 UITableViewCell 的 contentView 上的自定义绘图下方的 uiview 上的渐变。

这就是我在 UITableViewController 的 tableView:cellForRowAtIndexPath 中添加重叠效果的方法:

- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"APostCell";
PostCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

// Configure the cell...
CustomPost *aPost = [self.posts objectAtIndex:indexPath.row];

if (indexPath.row > 0) {
[cell addOverlap];
}
cell.postDateLabel.text = [aPost datePostedAsString];
return cell;
}

我将如何实现这个 [cell removeOverlap]?

最佳答案

试试这个

if (indexPath.row == 0) {
//remove overlap here

} else {

[cell addOverlap];
}

因为,除了第一个单元格外,所有单元格都有重叠。滚动时,重复使用的单元格有重叠。因此,对于第一个单元格,如果存在重叠,请将其删除。

关于ios - 重用后如何使自定义 UITableViewCell 顶部单元格唯一绘制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21447979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com