I have two nib files which are RowRecordLayout and ColumnLayout respectively.
I do register the nib cells to UICollectionView for be used later in cellForItemAtIndexPath function. Here is my code
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!
}
and finally when i touch on DJ button. The animation between transition is ok except the unexpected Constraint inside the cells
Here is the code of Transition layout
@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
}
})
}
}
The content inside cells are back to normal when i scroll up or down. Any solution to fix this ?