Я использовал YPDrawSignatureView для ячейки TableView, при прокрутке табличного представления ячейки являются дублирующими сигнатурами, кто-нибудь знает, как это решить.
моя функция cellForRow:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCell(withIdentifier: Constants.signatureTabelViewCell ) as! SignautreTableViewCell
let signatureData = signature[indexPath.row]
cell = SignautreTableViewCell.configureCell(cell: cell, forSignature: signatureData, atIndex: indexPath.row)
cell.delegate = self
return cell }
class Signature {varНазвание: Строка! var view: YPDrawSignatureView! }
протокол DataSourceUpdateDelegate: class {func signatureValueChanged (ячейка: SignautreTableViewCell, nameChanged updatedValue: String, viewChanged: YPDrawSignatureView)}
// cellEeBeateLeGateLeGeateLeGateLeCeateLeCeateLeGateLeCeateLeCeateLeCateLeGeTeCeTeGeTeeGe. {
@IBOutlet var textField: UITextField!
@IBOutlet weak var signatureView: YPDrawSignatureView!
weak var delegate: DataSourceUpdateDelegate?
override func awakeFromNib() {
super.awakeFromNib()
textField.delegate = self
signatureView.delegate = self
}
override func prepareForReuse() {
super.prepareForReuse()
}
class func configureCell(cell: SignautreTableViewCell, forSignature signature: Signature, atIndex index: Int) -> SignautreTableViewCell {
cell.tag = index
cell.textField.text = signature.name
cell.signatureView = signature.view
return cell
}
func textFieldDidEndEditing(_ textField: UITextField) {
self.delegate?.signatureValueChanged(cell: self, nameChanged: textField.text!, viewChanged: signatureView)
}
// Function for clearing the content of signature view
@IBAction func clearSignature(_ sender: UIButton) {
// This is how the signature gets cleared
self.signatureView.clear()
}
// Function for saving signature
@IBAction func saveSignature(_ sender: UIButton) {
// Getting the Signature Image from self.drawSignatureView using the method getSignature().
if let signatureImage = self.signatureView.getSignature(scale: 10) {
// Saving signatureImage from the line above to the Photo Roll.
// The first time you do this, the app asks for access to your pictures.
UIImageWriteToSavedPhotosAlbum(signatureImage, nil, nil, nil)
// Since the Signature is now saved to the Photo Roll, the View can be cleared anyway.
self.signatureView.clear()
}
}
}
расширение SignautreTableViewCell: YPSignatureDelegate {
func didStart(_ view: YPDrawSignatureView) {
print("Started Drawing")
self.delegate?.signatureValueChanged(cell: self, nameChanged: textField.text!, viewChanged: view)
}
func didFinish(_ view: YPDrawSignatureView) {
print("Finished Drawing")
self.delegate?.signatureValueChanged(cell: self, nameChanged: textField.text!, viewChanged: view)
}
}