У меня есть представление о таблице, которое показывает множество подписных просмотров с деталями гостей. Когда клетки прокручивают, сигнатура из ячейки 1 повторяется в ячейке 6 и 2 в ячейке 7 и так далее. (Повторное представление о таблице задача ячейки) В другом подходе я попытался очистить массив представлений подписи, которые держат сигнатуру в функции повторного использования. и когда ячейка создается в то время, основанное на пути индекса, который представление Cell.Signature добавляется в массив и сохраняется. Повторение. < /p>
Я могу предоставить код того, что я попробовал.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellReusableId = String(describing: ProfileSignataureTableViewCell.self)
guard let cell = tableView.dequeueReusableCell(withIdentifier: cellReusableId, for: indexPath) as? ProfileSignataureTableViewCell
else { fatalError("Cell not exists in storyboard") }
cell.firstNameText.delegate = self
cell.lastNameText.delegate = self
cell.ageText.delegate = self
cell.firstNameText.tag = indexPath.row
cell.lastNameText.tag = indexPath.row
cell.ageText.tag = indexPath.row
// cell.signatureView.tag = indexPath.row
cell.signatureView?.delegate = self
cell.signatureView?.tag = indexPath.row
if let existingSignature = signArray.first(where: { $0.indexPath == indexPath.row })?.signatureViews {
// Reuse the existing signature view if found
cell.signatureView = existingSignature
print("Reusing existing signature view for row \(indexPath.row)")
// use the existing signature views array to draw the signature back again not png data
if let signatureData = existingSignature.pathArray as? [Any] {
cell.signatureView?.pathArray = signatureData as! NSMutableArray
}
} else {
if let signatureView = cell.signatureView {
// Save the new signature view in the array
signArray.append(Signatures(indexPath: indexPath.row, signatureViews: signatureView))
print("Stored new signature view for row \(indexPath.row)")
} else {
print("No signature view available for row \(indexPath.row)")
}
}
cell.btn_clear.tag = indexPath.row
cell.btn_clear.addTarget(self, action: #selector(editButtonPressed), for: .touchUpInside)
print("the new array count is \(signArray.count)")
return cell
}
struct Signatures {
var indexPath: Int?
var signatureViews: SamsoSignatureView?
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... -inside-it