'UICollectionViewCell' 类型的值没有成员 'page'
Value of type 'UICollectionViewCell' has no member 'page'
我有一个自定义的 class 用于 UICollectionViewCell,但我无法访问它在 ViewController 中调用的页面中的 属性。
我做了什么:
1) 我创建了一个名为 Page 的 属性 页面。
2) 我已将自定义 class 添加到单元格。
如何使用 as!
强制将 cell
强制转换为 PageCellCollectionViewCell
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
}
我有一个自定义的 class 用于 UICollectionViewCell,但我无法访问它在 ViewController 中调用的页面中的 属性。 我做了什么:
1) 我创建了一个名为 Page 的 属性 页面。
2) 我已将自定义 class 添加到单元格。
如何使用 as!
cell
强制转换为 PageCellCollectionViewCell
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
}