gpt4 book ai didi

ios - 在 UITableView 中滚动时 CustomCell 图像发生变化

转载 作者:行者123 更新时间:2023-11-29 11:35:48 27 4
gpt4 key购买 nike

问题:滚动表格时API再次调用。
我完成的代码:

- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
ITableViewCell* cell = ( ITableViewCell* )[self.tblNotes dequeueReusableCellWithIdentifier:@"NoteTableCell"];

cell.tag = indexPath.row;
if(cell.tag == indexPath.row) {
cell = [cell initWithNote:[notesArray objectAtIndex:indexPath.row]];
}
[cell setNeedsLayout];
[cell setNeedsDisplay];
return cell;
}

我不想在滚动时调用 initWithNote

提前致谢。

最佳答案

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

ITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"NoteTableCell"];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"NoteTableCell" owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
}

id object = [notesArray objectAtIndex:indexPath.row];
if ([object isKindOfClass:[NSDictionary class]]) {
NSDictionary *dict = (NSDictionary *)object;
[cell.userNameforNotes setText:[NSString stringWithFormat:@"%@",[[dict valueForKey:@"uploadedBy"] uppercaseString]]];
[cell.noteDescription setText:[NSString stringWithFormat:@"%@",[[dict valueForKey:@"description"] uppercaseString]]];
[cell.dateForNotes setText:[NSString stringWithFormat:@"%@",[[dict valueForKey:@"uploadedDate"] uppercaseString]]];
NSString *urlString = [NSString stringWithFormat:@"%@", [dict valueForKey:@"incidentID"]];
[cell.noteImage sd_setImageWithURL:[NSURL URLWithString:urlString]];
}
return cell;
}

关于ios - 在 UITableView 中滚动时 CustomCell 图像发生变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49421141/

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