代码之家  ›  专栏  ›  技术社区  ›  kamalakshi hegde

“UICollectionViewCell”类型的值没有成员“page”

  •  1
  • kamalakshi hegde  · 技术社区  · 8 年前

    我有一个UICollectionViewCell的自定义类,但我无法访问其中名为ViewController中page的属性。 我所做的:

    1) 我创建了一个名为page的属性,它的类型为page。

    2) 我已将自定义类添加到单元格中。

    image of custom class

    image of inspector

    image of method in viewController

    1 回复  |  直到 8 年前
        1
  •  3
  •   Cruz    8 年前

    类型强制铸造如何 cell PageCellCollectionViewCell 使用 as!

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: 
    "cellID", for: indexPath) as! PageCellCollectionViewCell
        let page = pages[indexPath.item]
        cell.page = page
        return cell
    }