我有一个tableview填充名称和图像的数组。我已经通过继承UITableViewCell添加了一个自定义单元格。自定义单元格包含UIImage,其模式设置为“Aspect Fill”,并将高度和宽度设置为52以整齐地放入我的自定义单元格中。当我运行应用程序时,它会加载所有图像,并按照我指定的尺寸正确地将它们放入我的容器视图中。问题是每当我滚动视图时,重用单元显示图像就好像我没有自定义单元格一样。换句话说,不正确。这里是我的cellForRowAtIndexPath方法自定义tableViewCell滚动时显示不正确
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = @"Cell";
customCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
contact = contactsArray[indexPath.row];
NSString *firstName = contact[@"mutableFirstName"];
NSString *lastName = contact[@"mutableLastName"];
UIImage *image = contact[@"mutableImage"];
cell.imageView.image = image;
cell.firstNameLabel.text = firstName;
cell.lastNameLabel.text = lastName;
return cell;
}
你使用故事板? – amar
是的,我正在使用故事板 – user2076367
然后将“单元格”设置为单元格标识符 – amar