gpt4 book ai didi

ios - UITableViewCell 在滚动后被复制

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:45:53 25 4
gpt4 key购买 nike

<分区>

虽然已经有人问过关于这个问题的一些问题,但我似乎无法解决我的问题。问题是,当我滚动或重新加载我的 UITableView 时,单元格会重复。我知道问题与细胞的重复使用有关。这是出现问题的屏幕截图:

http://imgur.com/JrnERSD

这是我用来自定义单元格外观的代码:

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

static NSString *cellID = @"DividendCell";

DividendCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];

if (cell == nil)
{
[tableView registerNib:[UINib nibWithNibName:cellID bundle:nil] forCellReuseIdentifier:cellID];
cell = [tableView dequeueReusableCellWithIdentifier:cellID];
}

dividend *div = [[[aAgendaItems objectAtIndex:indexPath.section] agendaItems] objectAtIndex:indexPath.row];
[cell setDiv:div];

return cell;

我将 Xib 用于自定义单元格。

希望有人能帮帮我!

编辑:

这是 setDiv 方法将数据应用到行的代码:

-(void)setDiv:(dividend *)div {
NSString *text = [[NSString alloc] initWithString:[[[div RelatedIssue] ShortName] capitalizedString]];
[issueName setText:text];
[text release];

text = [[NSString alloc] initWithString:[div Description]];
[issueType setText:text];
[text release];

text = [[NSString alloc] initWithString:[div Currency]];
[issueCurrency setText:text];
[text release];

text = [[NSString alloc] initWithString:[super formatDouble:[div BrutValue]]];
[issueKoers setText:text];
[text release];

NSDateFormatter *format = [[NSDateFormatter alloc] init];
NSLocale *loc = [[NSLocale alloc] initWithLocaleIdentifier:@"nl_NL"];
[format setLocale:loc];
[format setDateFormat:@"dd MMM"];

text = [[NSString alloc] initWithString:[format stringFromDate:[div ExDividendDate]]];
[exDividendDate setText:text];
[text release];

NSComparisonResult result = [[div PaymentDate] compare:[NSDate date]];
text = [[NSString alloc] initWithString:[format stringFromDate:[div PaymentDate]]];
if (result==NSOrderedAscending) {
[exPaymentDate setTextColor:[UIColor darkGrayColor]];
} else {
[exPaymentDate setTextColor:[UIColor blackColor]];
}
[exPaymentDate setText:text];
[text release];
[loc release];

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