Commit 6fbfcb75 by Daniel Dahan

development: added default registry of CollectionViewCell to CollectionView

parent fc9c0582
......@@ -127,7 +127,7 @@ extension CardCollectionViewController: CollectionViewDataSource {
}
dataSourceItemsIndexPaths[indexPath] = card
card.frame = cell.bounds
cell.card = card
......
......@@ -104,21 +104,24 @@ open class CollectionView: UICollectionView {
An initializer that initializes the object.
- Parameter collectionViewLayout: A UICollectionViewLayout reference.
*/
public convenience init(collectionViewLayout layout: UICollectionViewLayout) {
self.init(frame: .zero, collectionViewLayout: layout)
public init(collectionViewLayout layout: UICollectionViewLayout) {
super.init(frame: .zero, collectionViewLayout: layout)
prepare()
}
/**
An initializer that initializes the object.
- Parameter frame: A CGRect defining the view's frame.
*/
public convenience init(frame: CGRect) {
self.init(frame: frame, collectionViewLayout: CollectionViewLayout())
}
public init(frame: CGRect) {
super.init(frame: frame, collectionViewLayout: CollectionViewLayout())
prepare()
}
/// A convenience initializer that initializes the object.
public convenience init() {
self.init(frame: .zero)
public init() {
super.init(frame: .zero, collectionViewLayout: CollectionViewLayout())
prepare()
}
/**
......@@ -131,5 +134,6 @@ open class CollectionView: UICollectionView {
open func prepare() {
backgroundColor = .white
contentScaleFactor = Screen.scale
register(CollectionViewCell.self, forCellWithReuseIdentifier: "CollectionViewCell")
}
}
......@@ -251,6 +251,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable, PulseableLayer {
when subclassing.
*/
open func prepare() {
backgroundColor = .white
contentScaleFactor = Screen.scale
prepareVisualLayer()
preparePulse()
......
......@@ -112,6 +112,7 @@ extension CollectionViewController {
}
extension CollectionViewController: CollectionViewDelegate {}
extension CollectionViewController: CollectionViewDataSource {
@objc
open func numberOfSections(in collectionView: UICollectionView) -> Int {
......@@ -125,6 +126,6 @@ extension CollectionViewController: CollectionViewDataSource {
@objc
open func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
return UICollectionViewCell()
return collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionViewCell", for: indexPath)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment