如何将多个 objects 传递给 IGListKit Section Controller

How to pass multiple objects to IGListKit Section Controller

我正在使用 IGListStackedSectionController,我想知道如何将多个 objects 传递给任何给定的孩子。

我有这样一个场景:

let sectionController = IGListStackedSectionController(sectionControllers: [
            WorkingRangeSectionController(),
            DisplaySectionController(),
            HorizontalSectionController(),
            ])!

假设我想在第一部分放置一个动态标题,在第二部分放置一组图像,在最后一部分放置一组不同的图像。

我该怎么做?

非常感谢!

简答:

你不能这样做。相同的对象被传递给所有子部分控制器。

长答案:

您可以将所有必要的数据组合成一个 class,例如:

class Model {
    var title = ""
    var images = [UIImage]()
    var otherImages = [UIImage]()
}

您还需要根据需要实现IGListDiffable协议。

GitHub 上的 IGListKit 个示例中有 IGListStackedSectionController 的简短示例。