【问题标题】:Build error when binding a `RxTableViewSectionedAnimatedDataSource` to a UITableView将“RxTableViewSectionedAnimatedDataSource”绑定到 UITableView 时生成错误
【发布时间】:2015-12-04 16:22:44
【问题描述】:

RxTableViewSectionedAnimatedDataSource 用于UITableView 的rx_itemsAnimatedWithDataSource() 时出现以下错误。

这是错误的屏幕截图:

无法使用参数列表调用“rx_itemsAnimatedWithDataSource” 类型 '(RxTableViewSectionedAnimatedDataSource)'

需要一个类型为“(DataSource)”的参数列表

self.dataSource 的类型为:

RxTableViewSectionedAnimatedDataSource< DateSelectorSectionModel>

这是为DateSelectorSectionModel 生成的接口,以及相关类型:

typealias DateSelectorSectionModel = SectionModel<SectionDesc, SectionDesc>

enum SectionType {
    case StartDate, EndDate, TimeZone, AllDay
}

enum SectionState {
    case Present, Missing, Dirty
}

enum SectionSelection {
    case NotSelected, Selected
}

struct SectionDesc {
    var type: SectionType
    var state: SectionState
    var selectionState: SectionSelection
    init(type: SectionType, state: SectionState, selection: SectionSelection)
    public func getSectionModel() -> DateSelectorSectionModel
}

extension EventDetailsDateSelectorViewModel {
    public var rows: RxCocoa.Driver<[DateSelectorSectionModel]> { get }
}

有什么想法吗?谢谢!

【问题讨论】:

    标签: ios swift uitableview rx-swift


    【解决方案1】:

    我发现了问题。

    对于动画数据源,正确的模型应该是HashableSectionModel 类型。这意味着:

    // Instead of this:
    typealias DateSelectorSectionModel = SectionModel<SectionDesc, SectionDesc>
    // Do this:
    typealias DateSelectorSectionModel = HashableSectionModel<SectionDesc, SectionDesc>
    

    通过此更改,一切都按预期编译。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-19
      • 1970-01-01
      相关资源
      最近更新 更多