我有兩個nib文件分別是RowRecordLayout和ColumnLayout。 佈局在UICollectionViewCel看起來很奇怪,當執行setCollectionViewLayout
我做登記筆尖細胞UICollectionView被用於在cellForItemAtIndexPath功能以後使用。這裏是我的代碼
override func viewDidLoad() {
self.DJCollectionView.registerNib(UINib(nibName: "RowTemplateCell", bundle: NSBundle.mainBundle()), forCellWithReuseIdentifier: "DJCELL")
self.DJCollectionView.registerNib(UINib(nibName: "ColumnTemplateCell", bundle: NSBundle.mainBundle()), forCellWithReuseIdentifier: "DJCELL2")
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath
indexPath: NSIndexPath) -> UICollectionViewCell {
var ProductCardCellpt : DJCell?
if self._CurrentLayoutType == enum_Layout.RowRecords {
reuseIdentifier = "DJCELL"
ProductCardCellpt = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as? DJCell
…
}else{
reuseIdentifier = "DJCELL2"
ProductCardCellpt = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as? DJCell
...
}
return ProductCardCellpt!
}
最後當我觸摸DJ按鈕。轉變之間的動畫是確定除了所述細胞
這裏內部的意外約束是過渡佈局的代碼
@IBAction func Action_ToggleLayout(sender: UIBarButtonItem) {
if _CurrentLayoutType == enum_Layout.TwoColumn {
_CurrentLayoutType = enum_Layout.RowRecords
self.DJCollectionView.setCollectionViewLayout(self._RowRecordsLayout_CollectionViewLayout!, animated: true, completion: { (IsDone) -> Void in
})
}
else{
_CurrentLayoutType = enum_Layout.TwoColumn
self.DJCollectionView.setCollectionViewLayout(self._TwoColumnLayout_CollectionViewLayout!, animated: true, completion: { (IsDone) -> Void in
}
})
}
}
在細胞內的內容均恢復正常時,我向上滾動或下。 任何解決方案來解決這個問題?
你可以把的CollectionView佈局在筆尖文件?你只能把UICollectionViewCell放入筆尖,不是嗎? –
它們是筆尖中的UICollectionViewCell。 – Deathz
你什麼時候改變了collectionView的佈局? –