gpt4 book ai didi

ios - UITableView 在 ios 中使用自定义表格单元格滚动不流畅

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

我正在使用自定义单元格。这里我加载两个图像和四个标签。 TableView 滚动不平滑。这是我的代码。

        static NSString *simpleTableIdentifier = @"SimpleTableCell";

CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCellSixPlus" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.cellButtonOutlet.tag = indexPath.row;
[cell.cellButtonOutlet addTarget:self action:@selector(yourButtonClicked:) forControlEvents:UIControlEventTouchUpInside];


NSManagedObjectModel *device = [self.devices objectAtIndex:indexPath.row];


long int index1 = [languageCode indexOfObject: [NSString stringWithFormat:@"%@",[device valueForKey:@"sourceLang"]]];
long int index2 = [languageCode indexOfObject: [NSString stringWithFormat:@"%@",[device valueForKey:@"destinationLang"]]];


cell.nameLabel1.text = [languageName objectAtIndex:index1];
cell.nameLabel2.text = [languageName objectAtIndex:index2];

cell.nameLabel3.text = [NSString stringWithFormat:@"%@",[device valueForKey:@"sourceText"]];
cell.nameLabel4.text = [NSString stringWithFormat:@"%@",[device valueForKey:@"transilateText"]];

cell.sourceFlagImageview.image = [UIImage imageNamed:[languageName objectAtIndex:index1]];
cell.translateFlagImageview.image = [UIImage imageNamed:[languageName objectAtIndex:index2]];

return cell;

通过增加单元高度解决问题

最佳答案

评论下面的代码行并重试:

long int index1 = [languageCode indexOfObject: [NSString stringWithFormat:@"%@",[device valueForKey:@"sourceLang"]]];
long int index2 = [languageCode indexOfObject: [NSString stringWithFormat:@"%@",[device valueForKey:@"destinationLang"]]];

cell.sourceFlagImageview.image = [UIImage imageNamed:[languageName objectAtIndex:index1]];
cell.translateFlagImageview.image = [UIImage imageNamed:[languageName objectAtIndex:index2]];

如果它能正常工作,那么你需要在后台队列中分配图像

关于ios - UITableView 在 ios 中使用自定义表格单元格滚动不流畅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40012378/

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