Пользовательские элементы UICollectionReusableView не отображаются - PullRequest
0 голосов
/ 11 июля 2019

Часть заголовка UICollectionView.

class HeaderView: UICollectionReusableView {

    @IBOutlet weak var lbl_HeaderText: UILabel!
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
}

Установка значения для заголовка.

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

    let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "HeaderView", for: indexPath)

    headerView.lbl_HeaderText = "Some Text"
    return headerView

}
}

lbl_HeaderText не показывает для ссылки подкласса на headerView ссылки только на UICollectionReusableView не показывает или имеет свойство HeaderView

1 Ответ

0 голосов
/ 11 июля 2019

API требует, чтобы вы зарегистрировали дополнительный вид с помощью

func register(AnyClass?, forSupplementaryViewOfKind: String, withReuseIdentifier: String)

или

func register(UINib?, forSupplementaryViewOfKind: String, withReuseIdentifier: String)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...