У меня есть следующее -
class BTTableView: UITableView, UITableViewDelegate, UITableViewDataSource
С помощью этих методов -
public func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
public func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
return .delete
}
public func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath)
{
print("editingStyle")
}
Когда я проводил пальцем по ячейке, опция «Удалить» показывает, как и ожидалось - Показанное действие удаления
Если при нажатии I -
- удалить указанный выше метод с параметром 'commit editStyle' не вызывается,
- проведите пальцем влево по всемПри переходе к Delete, вместо того, чтобы останавливаться, когда появляется Delete, вызывается метод.
Мне кажется, этот метод будет вызываться как с # 1, так и с # 2.
Может ли кто-нибудь помочь мне понять, что я сделал неправильно?
РЕДАКТИРОВАТЬ - С помощью ввода DonMag решена проблема с:
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
if let hitView = super.hitTest(point, with: event) {
let isSwipeButton = String(describing: type(of: hitView)) == "UISwipeActionStandardButton"
if hitView.isKind(of: BTTableCellContentView.self) || isSwipeButton {
return hitView
}
}
return nil;
}