0
我在cellForItemAtIndexPath
內部實現了單元格內容,只是在內部添加了UIImageView
以及繪製和居中的圖像,它看起來不錯,直到我滾動收藏視圖!!!看圖片!UICollectionViewCell滾動內容問題
// ...........cell content setup
switch indexPath.row {
case 0:
cell.alpha = 0.0
case 1:
// ...........drawing singular on cell content view
var cellImageView = UIImageView(frame: CGRectMake(0, 0, cell.frame.size.width, cell.frame.size.height))
cellImageView.image = MyStyles.imageOfSingular(frame: CGRectMake(0, 0, 50.5, 50.5))
cellImageView.contentMode = UIViewContentMode.Center
cell.backgroundView = cellImageView
// ...........
你可以看到滾動之後有出現在細胞indexPath 3圖像我並不需要它有! 我不知道該如何處理! SOS
最終的圖片看起來像這樣
但滾動後,它看起來像這樣
我處理文本複製這樣:
// ...........title setup and check if cellTitle exists to avoid title overlaping
let cellTitle = UILabel(frame: CGRectMake(0, 0, cell.frame.size.width, cell.frame.size.height))
for cellTitle in cell.contentView.subviews {
if (cellTitle.isKindOfClass(UILabel)) {
cellTitle.removeFromSuperview()
}
}
不過不要不知道如何處理圖像!
你知道單元格在你滾動時被重用嗎?做一個細胞重用的搜索,你應該找到一些答案。 – rdelmar 2015-02-08 20:59:58
交換機的用途是什麼?你爲什麼不設置圖像? – CaptJak 2015-02-08 21:07:09
是的,我瞭解細胞再利用! – Ruso 2015-02-08 21:34:58