I have the following -
class BTTableView: UITableView, UITableViewDelegate, UITableViewDataSource
With these methods -
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")
}
When I left swipe on a cell, the 'Delete' option shows as expected - Delete action shown
If I -
It seems to me this method would be called with both #1 & #2.
Can someone help me understand what I've done wrong?
EDIT - With DonMag's input, solved issue with:
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;
}
It appears commit
is not being called because that class is overriding hitTest
:
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
if let hitView = super.hitTest(point, with: event) , hitView.isKind(of: BTTableCellContentView.self) {
return hitView
}
return nil;
}
and returning nil
because hitView
is then the action button.
Simply removing it may/will cause issues (first one noticed is that the "drop down" doesn't close when tapping outside of it).
So you'll need to edit that function... might take a little work, but that's the place to start.