Closed csr closed 4 years ago
Hi @csr, thanks for reaching out.
We've moved to a slightly different model here to better take advantage of the APIs exposed in iOS 11+, specifically the UISwipeActionsConfiguration
. This allows images and full row swipe as well as having both leading and trailing actions.
I've tweaked your example a bit to show how the new version would work. One note is that I had to change the call to self.didTapDeleteOnRow
to self.didTapDeleteOnItem
since an IndexPath
isn't available anymore.
let rows: [CellConfigType] = getSourceArray().enumerated().map { index, item in
let deleteAction = CellActions.SwipeActionsConfiguration.ContextualAction(title: "Delete", backgroundColor: UIColor.red, style: .destructive) { _, completion in
self.didTapDeleteOnItem(item)
completion(true) // The true signifies a successful deletion
}
return HistoryCell(
key: "index-\(index)-\(item.translatedText)",
style: cellStyle,
actions: CellActions(
selectionAction: { _ in
self.didSelectCell(translation: item)
return .selected
},
deselectionAction: { _ in
return .deselected
},
trailingActionConfiguration: CellActions.SwipeActionsConfiguration(actions: [deleteAction]) // <---- here
),
state: HistoryState(translationItem: item),
cellUpdater: HistoryState.updateView)
}
Hi, I previously used to delete rows by specifying a
UITableViewRowAction
inrowActions
property like soNow I see
rowActions
isn't part of the initializer anymore, so I'm wondering how to enable cell deletion. Any insights?