According to your requirement:
I want actions for rows, but I don't want the default behaviour in iOS11 of performsFirstActionWithFullSwipe. If I just implement editActionsForRowAt then iOS11 does the full swipe.
In iOS-10 and below,
to get the edit actions work in a UITableView, just implement the below methods:
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool
{
return true
}
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]?
{
let deleteAction = UITableViewRowAction(style: .destructive, title: "Delete") { (action, indexpath) in
//YOUR_CODE_HERE
}
deleteAction.backgroundColor = .red
return [deleteAction]
}
In iOS-11,
2 new methods were introduced to support editing in a UITableView, i.e. leadingSwipeActionsConfigurationForRowAt and trailingSwipeActionsConfigurationForRowAt.
According to Apple,
Swipe actions
These methods supersede
-editActionsForRowAtIndexPath: if implemented
return nil to get the default swipe actions
So, you can implement these 2 methods to get the iOS-11 specific behaviour. Even if you don't editActionsForRowAt will be called.
If you don't want the default full swipe behaviour of edit action in iOS-11, just set performsFirstActionWithFullSwipe to false.
Example:
@available(iOS 11.0, *)
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?
{
return nil
}
@available(iOS 11.0, *)
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?
{
let deleteAction = UIContextualAction(style: .destructive, title: "Delete") { (action, view, handler) in
//YOUR_CODE_HERE
}
deleteAction.backgroundColor = .red
let configuration = UISwipeActionsConfiguration(actions: [deleteAction])
configuration.performsFirstActionWithFullSwipe = false
return configuration
}
Let me know if you still face any issues.