选定后,表格视图中的图像会更改大小

时间:2018-11-11 20:59:08

标签: ios swift image select tableview

当选择一个单元格时,我添加到表格视图中的图像正在改变大小。我找到了很多解决方案,但对我没有任何帮助。我使用“内置”图像视图。不知道这是问题吗?如果您能帮助我,我将不胜感激:)

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)

    //        cell.textLabel?.text = docArray[indexPath.row]
    cell.textLabel?.attributedText = NSAttributedString(string: docArray[indexPath.row], attributes: [NSAttributedString.Key.foregroundColor : UIColor.blue, NSAttributedString.Key.font : UIFont(name: "Chalkduster", size: 17)])
    cell.textLabel?.adjustsFontSizeToFitWidth = true
    cell.textLabel?.numberOfLines = 4
    cell.imageView?.downloaded(from: imageArray[indexPath.row])



    return cell
}
}

1 个答案:

答案 0 :(得分:0)

似乎您在此处下载了图像

cell.imageView?.downloaded(from:imageArray[indexPath.row])

1-设置

cell.imageView?.clipsToBounds = true

2-使用SDWebImage

cell.imageView?.sd_setImage(with: URL(string: imageArray[indexPath.row]), placeholderImage: UIImage(named: "placeholder.png"))