Ios 如何使用数组设置单元格内容?

Ios 如何使用数组设置单元格内容?,ios,arrays,uitableview,Ios,Arrays,Uitableview,我有一个字符串数组,用于检索单元格的图像。 当我运行代码时,图像没有放在正确的单元格中。如何让它们以正确的顺序显示 myArray = @[@"string1", @"string2", @"string3", nil]; //for example [cell setImageUsingString:[myArray objectAtIndex:indexPath.row]]; 创建自定义单元格类,向其中添加UIImageView,然后使用以下代码 UITableViewCell *cel

我有一个字符串数组,用于检索单元格的图像。 当我运行代码时,图像没有放在正确的单元格中。如何让它们以正确的顺序显示

myArray = @[@"string1", @"string2", @"string3", nil]; //for example

[cell setImageUsingString:[myArray objectAtIndex:indexPath.row]];

创建自定义单元格类,向其中添加UIImageView,然后使用以下代码

UITableViewCell *cell = [myTableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    cell.myImageView.image = [UIImage imageNamed:[imagesArray objectAtIndex:(int)indexPath.row]];

发布更多来自CellForRowatineXpath的代码记住tableview重用cellsThank,我已经试过了,但它对我不起作用。我在自定义单元格中设置了setImageUsingString方法,因为我需要在获得相应字符串后下载图像。但问题是我的图像没有按正确的顺序设置。根据对您问题的评论,您需要显示更多代码,但我猜您的图像加载是异步完成的,并且您使用的变量引用了目标单元格,该单元格在下载启动到下载完成之间发生了更改