首页 > 解决方案 > 使用 RxTableViewSectionedReloadDataSource 配置单元格时如何设置单元格委托

问题描述

我有一个委托方法,我想在点击单元格中的按钮时执行该方法。我使用 RxTableViewSectionedReloadDataSource 配置了我的单元格,当我在此处设置委托时,它说它们是我不理解的不相关类型,因为我的 viewController 继承了委托并实现了它的方法。

let notificationsDataSource = RxTableViewSectionedReloadDataSource<SectionOfCustomData>(
        configureCell: {dataSource, tableView, indexPath, item in
            guard let cell = tableView.dequeueReusableCell(withIdentifier: "NewNotificationTableViewCell", for: indexPath) as? NewNotificationTableViewCell else { return UITableViewCell() }
            cell.configureCell(item: item, indePath: indexPath)
            cell.notificationDeleteDelegate = self
            return cell
    })

我收到此错误“无法分配类型'(NotificationViewController)->()-> NotificationViewController'的值来键入'TableViewCellDeleteDelegate?'”

标签: rx-swift

解决方案


似乎 NotificationViewController 不符合 TableViewCellDeleteDelegate ......

extension NotificationViewController: TableViewCellDeleteDelegate {
   // TableViewCellDeleteDelegate Methods here
}

推荐阅读