При обновлении таблицы (tableView.reloadData()) UIimageView показывается на других ячейках

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cellid", for: indexPath)
    let image = UIImageView()
    let imagestyle = UIImage(systemName: "person.circle.fill")
    image.tintColor = .systemGray3
    
    cell.textLabel?.text = nameforcell[indexPath.section]
    
    if indexPath.section == 0 {
        cell.backgroundColor = .clear
        image.frame = CGRect (x: cell.frame.width / 2 - 50  , y: 0, width: 100, height: 95)
        image.image = imagestyle
        cell.addSubview(image)
    }else if indexPath.section == 1 {
        cell.accessoryType = .disclosureIndicator
    }else if indexPath.section == 2 {
        cell.accessoryType = .disclosureIndicator
    }else if indexPath.section == 3 {
        cell.accessoryType = .disclosureIndicator
    }else if indexPath.section == 4 {
        cell.accessoryType = .disclosureIndicator
    }else if indexPath.section == 5 {
        cell.accessoryType = .disclosureIndicator
    }
    
    return cell
}

До обновлненияПосле обновления


Ответы (0 шт):