问题描述
我在RxSwift
框架中使用RxDataSources
来建立表格视图:
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)
我正在尝试让UISwipeActionsConfiguration
在UITableViewDelegate
中工作,并将委托设置为:
tableView.rx.setDelegate(self).disposed(by: bag)
同时将委托方法设置为:
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
}
}
在不使用RxSwift的情况下执行此操作可进行滑动操作。
有人知道如何让trailingSwipeActionsConfigurationForRowAt
与RxDatasources一起工作,因为我只能让viewForHeaderInSection
与RxDatasources合作?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)