【问题标题】:Custom UICollectionReusableView elements not shown未显示自定义 UICollectionReusableView 元素
【发布时间】:2019-07-11 00:05:50
【问题描述】:

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”属性

【问题讨论】:

    标签: ios uicollectionview uicollectionreusableview


    【解决方案1】:

    API 要求您向

    注册补充视图
    func register(AnyClass?, forSupplementaryViewOfKind: String, withReuseIdentifier: String)
    

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

    【讨论】:

      猜你喜欢
      • 2018-09-18
      • 1970-01-01
      • 2018-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-12
      • 2016-12-12
      相关资源
      最近更新 更多