SoySauceLab / CollectionKit

Reimagining UICollectionView
MIT License
4.4k stars 259 forks source link

I'm facing weird issue in header example #121

Closed abdallahnh closed 5 years ago

abdallahnh commented 5 years ago

Cannot convert value of type '(UILabel, , ) -> ()' to expected argument type 'ViewSource<ComposedHeaderProvider<_>.HeaderData, _>'

` override func viewDidLoad() { super.viewDidLoad()

    toggleButton.addTarget(self, action: #selector(toggleSticky), for: .touchUpInside)
    view.addSubview(toggleButton)

    collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 44, right: 0)

    let sections: [Provider] = (1...1).map { _ in
        return BasicProvider(
            dataSource: ArrayDataSource(data: Array(1...9)),
            viewSource: ClosureViewSource(viewUpdater: { (view: SquareView, data: Int, index: Int) in
                view.backgroundColor = UIColor(hue: CGFloat(index) / 10,
                                               saturation: 0.68, brightness: 0.98, alpha: 1)
                view.text = "\(data)"
            }),
            sizeSource:  { (index, data, maxSize) -> CGSize in
                return CGSize(width: 80, height: 80)
        },
            layout: FlowLayout(spacing: 10, justifyContent: .spaceAround, alignItems: .center)
                .inset(by: UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10))
        )
    }

    let provider = ComposedHeaderProvider(
        headerViewSource: { (view: UILabel, data, index) in
            view.backgroundColor = UIColor.darkGray
            view.textColor = .white
            view.textAlignment = .center
            view.text = "Header \(data.index)"
    },
        headerSizeSource: { (index, data, maxSize) -> CGSize in
            return CGSize(width: maxSize.width, height: 40)
    },
        sections: sections
    )

    self.headerComposer = provider
    self.provider = provider
}`

this code work fine in the example but when i take it and use in my code it gives above error

lkzhao commented 5 years ago

@abdallahnh The version of CollectionKit used in the example project is 2.3.0. which is just released right now. just do a pod update and you should be good.