I'm using RxSwift
with RxDataSources
framework to setup a tableview:
let dataSource = RxTableViewSectionedAnimatedDataSource<AnimatableSectionModel<String, String>>(configureCell: { _, tableView, indexPath, item -> UITableViewCell in
let cell = tableView.dequeueReusableCellwithIdentifier: "TestCell", for: indexPath)
cell.configure()
return cell
})
vm.cellViewModels
.map({ [AnimatableSectionModel(model: "", items: $0)] })
.bind(to: _view.tableView.rx.items(dataSource: dataSource))
.disposed(by: bag)
I'm trying to get my UISwipeActionsConfiguration
to work in UITableViewDelegate
, and setting the delegate as:
tableView.rx.setDelegate(self).disposed(by: bag)
At the same time setting the delegate methods as:
extension UIViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let action = UIContextualAction(style: .normal, title: nil) { action, view, completion in
}
action.image = Images.shared.logo.resized(to: CGSize(width: 24, height: 24)).tintWithColor(.darkGray).withRenderingMode(.alwaysOriginal)
action.backgroundColor = .clear
let configuration = UISwipeActionsConfiguration(actions: [action])
configuration.performsFirstActionWithFullSwipe = false
return configuration
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.bounds.size.width, height: 20))
headerView.backgroundColor = UIColor.red
return headerView
}
}
The header is called and works as expected, meaning the delegate should be set correct.
Doing it without RxSwift, works for swipe actions.
Does anyone know how to get trailingSwipeActionsConfigurationForRowAt
to work with RxDatasources, as I can only get viewForHeaderInSection
to work?