UICollectionReusableView method not being called

后端 未结 11 814
暗喜
暗喜 2021-01-31 13:13

I want my sections in the UICollectionView to have a header with an image.

I have followed these steps:

  • at the storyboard, assigned a header a
11条回答
  •  耶瑟儿~
    2021-01-31 13:59

    If you've got a generic subclass then you must take care to specify ObjC delegate method name if it's different then Swift name (https://bugs.swift.org/browse/SR-2817).

    @objc (collectionView:viewForSupplementaryElementOfKind:atIndexPath:)
    func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
    ...
    

提交回复
热议问题