gpt4 book ai didi

滚动后 iOS UITableViewCell 无法正确更新

转载 作者:行者123 更新时间:2023-11-29 12:15:26 26 4
gpt4 key购买 nike

这就是我所拥有的:我有一个带有自定义 UITableViewCell 的 TableView,它正在从 MutableArray 加载数据。

在我的 cellForRow: 我调用代码用数组中的数据绘制 subview ,当我向下滚动和向上滚动时,该 subview 看起来非常错误,但每个标签似乎都是正确的...

我在谷歌上尝试了很多答案,但都没有解决它,我什至将 subview 放到数组中,但也不起作用,抱歉,我还不能发布图片:(

NSMutableArray *mintHistoryList = //Array of Epin objects 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
// Configure the cell...

EPinObject *data;

if (indexPath.row < self.mintHistoryList.count && [[self.mintHistoryList objectAtIndex:indexPath.row] isKindOfClass:[EPinObject class]])
{
data = [self.mintHistoryList objectAtIndex:indexPath.row];
UILabel *pinGeneratedDateLabel = (UILabel *)[cell viewWithTag:100];
pinGeneratedDateLabel.text = data.pinGeneratedTime;

UILabel *pinNumberLabel = (UILabel *)[cell viewWithTag:101];
pinNumberLabel.text = data.pinCode;

UILabel *pinOriginalLabel = (UILabel *)[cell viewWithTag:102];
pinOriginalLabel.text = [NSString stringWithFormat:@"%@%@", [Common currencyFloatRemake:data.pinOriginalAmount],[Common currencyCodeToSymbol:data.pinCurrencyCode]];
pinOriginalLabel.adjustsFontSizeToFitWidth=YES;
pinOriginalLabel.minimumScaleFactor=0.5;

UILabel *pinLeftLabel = (UILabel *)[cell viewWithTag:103];
pinLeftLabel.text = [NSString stringWithFormat:@"%@%@ left", [Common currencyFloatRemake:data.pinLeftAmount],[Common currencyCodeToSymbol:data.pinCurrencyCode]];
pinLeftLabel.adjustsFontSizeToFitWidth=YES;
pinLeftLabel.minimumScaleFactor=0.5;

//THIS PART

UIView *circleView = (UIView *)[cell viewWithTag:104];
[circleView addSubview:[Customview alloc]initWithOriginal:data.pinOriginalAmount andLeft:data.pinLeftAmount];
}

数组没有变,其他标签也没有变,只是 subview 不对

正确: https://drive.google.com/file/d/0BwtBKpSMH_eHUWRfMkpzOTFaTkE/view?usp=sharing

向下和向上滚动: https://drive.google.com/file/d/0BwtBKpSMH_eHWkxmeDNGQUJvdnM/view?usp=sharing

最佳答案

我认为问题出在这里

UIView *circleView = (UIView *)[cell viewWithTag:104];
[circleView addSubview:[Customview alloc]initWithOriginal:data.pinOriginalAmount andLeft:data.pinLeftAmount];

当您重用单元格时,它将包含 2 个 circleView...你应该删除之前的那个,或者重用 circleView 本身

PS 图片对我不可用,我收到错误 403

关于滚动后 iOS UITableViewCell 无法正确更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32135167/

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