當滾動到底部然後備份時,我的收藏視圖單元格正在修改。滾動時更改的快速收藏視圖數據
在我的viewDidLoad我有一個分析查詢,它從數據庫中提取所有值,然後從主線程調用reloadData。
在初始加載時,可見單元格正確顯示。
但是,當我向下滾動不可見的單元格被加載,並且其中1/3顯示不正確。
然後,當我回滾到初始可見單元格時,第一個單元格不能正確顯示。
通過不正確顯示我的意思是在我的數據庫中是一個對齊的字段。這可以容納中心,左邊或右邊的字符串。
這個值是我的圖像和按鈕應該如何在單元格中對齊。
這是我的cellForRow函數。
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell{
let cell: FeedThumbnail = collectionView.dequeueReusableCellWithReuseIdentifier("feed_cell", forIndexPath: indexPath) as! FeedThumbnail
//handle cell alignment
if(align[indexPath.row] == "left"){
//leave alignment as is for buttons
if(cell.picture.frame.origin.x == 0){
cell.picture.frame.offsetInPlace(dx: -75, dy: 0)
}
}
else if(align[indexPath.row] == "center"){
cell.holder_view.frame.offsetInPlace(dx: 105 - cell.holder_view.frame.origin.x, dy: 0)
//leave image as is
}
else if(align[indexPath.row] == "right"){
cell.holder_view.frame.offsetInPlace(dx: 220 - cell.holder_view.frame.origin.x, dy: 0)
cell.picture.frame.offsetInPlace(dx: 100 - cell.picture.frame.origin.x, dy: 0)
}
return cell
}
這裏是類我的收藏觀察室
import UIKit
class FeedThumbnail: UICollectionViewCell {
@IBOutlet weak var picture: UIImageView!
@IBOutlet weak var comment_btn: UIButton!
@IBOutlet weak var heart_btn: UIButton!
@IBOutlet weak var rescip_btn: UIButton!
@IBOutlet weak var og_btn: UIButton!
@IBOutlet weak var name_lbl: UIButton!
@IBOutlet weak var holder_view: UIView!
}
您可以發佈您'FeedThumbnail'類? – RPK
我剛添加它。 – Basic
這些按鈕都在holder_view – Basic