代码之家  ›  专栏  ›  技术社区  ›  Paras Gorasiya

为2个数据源绑定单个表视图,并使用Bond根据所选段进行更新

  •  0
  • Paras Gorasiya  · 技术社区  · 6 年前

    我正试着绑定单身 UITableView 有2个数据源。 我的代码是这样的

    viewModel?.dataSource?.currentYear?.bind(to: tableViewMonths, cellType: StatementExportMonthTableViewCell.self) { (cell, name) in
                cell.updateWith(month: name)
            }
    
    viewModel?.dataSource?.previousYear?.bind(to: tableViewMonths, cellType: StatementExportMonthTableViewCell.self) { (cell, name) in
                cell.updateWith(month: name)
            }
    

    我无法弄清楚如何根据所选的段索引在表视图中显示正确的数据。 我知道我可以定义一个主数据源,根据段选择,我应该为该实例分配相应的数据源,并从中重新加载表视图。

    但如果Bond已经内置了该功能,我会尽量简化它。

    如有任何帮助,我们将不胜感激。

    谢谢

    0 回复  |  直到 6 年前