我对如何以正确的方式实现这些东西有疑问。 到此为止
if indexPath.row == 1 {
let indexPatha = NSIndexPath(forRow: 0, inSection: 0)
let changeCell = collectionView .cellForItemAtIndexPath(indexPatha) as! BarCollectionViewCell
changeCell.addNewBottleSecondButton.alpha = 0
}
但是当我滑动直到单元格被隐藏时,我收到错误消息,在展开可选值时意外发现 nil,而且这看起来仍然不像我想要的那样。 我想实现这一点,当我有多个单元格时,我想隐藏一个特定 View 。
最佳答案
在您的流程中,改为在 cellForRowAtIndexPath 中处理此问题是否可行?
初始化单元格后:
cell.addNewBottleSecondButton.hidden = (indexPath.row == 0) && (dataItems.count > 1)
关于ios - 在特定的 CollectionViewCell 中隐藏 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36066297/