FUICollectionViewTableViewCell
open class FUICollectionViewTableViewCell : NibDesignableFUIBaseTableViewCell
UITableViewCell
subclass, containing a full-frame collectionView. The FUICollectionViewTableViewCell
will resize its height to accomodate all the items in collection view.
## Usage
let workOrders: [WorkOrder] = []
let businessObjects: [BusinessObject] = []
override public func viewDidLoad() {
self.tableView.rowHeight = UITableView.automaticDimension
self.tableView.register(FUICollectionViewTableViewCell.self, forCellReuseIdentifier: FUICollectionViewTableViewCell.reuseIdentifier)
}
// MARK: UITableViewDataSource
override public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: FUICollectionViewTableViewCell.reuseIdentifier, for: indexPath) as! FUICollectionViewTableViewCell
cell.collectionView.setCollectionViewLayout(FUICollectionViewLayout.autosizingColumnFlow, animated: false)
cell.collectionView.dataSource = self
cell.collectionView.delegate = self
cell.collectionView.tag = indexPath.section
switch indexPath.section {
case 0:
cell.collectionView.register(FUIObjectCollectionViewCell.self, forCellWithReuseIdentifier: FUIObjectCollectionViewCell.reuseIdentifier)
case 1:
cell.collectionView.register(FUIItemCollectionViewCell.self, forCellWithReuseIdentifier: FUIItemCollectionViewCell.reuseIdentifier)
default:
break
}
return cell
}
// MARK: UICollectionViewDataSource
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
switch collectionView.tag {
case 0:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FUIObjectCollectionViewCell.reuseIdentifier,
for: indexPath) as! FUIObjectCollectionViewCell
let workOrder = workOrders[indexPath.item]
cell.detailImage = workOrder.image
cell.headlineText = workOrder.title
return cell
default:
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FUIItemCollectionViewCell.reuseIdentifier,
for: indexPath) as! FUIItemCollectionViewCell
let businessObject = businessObjects[indexPath.item]
cell.contentImage = businessObject.image
cell.titleText = businessObject.title
return cell
}
}
-
UICollectionView
subclass, which covers the bounds of the cell.Declaration
Swift
@IBOutlet public private(set) var collectionView: UICollectionView! { get }
-
Reuse identifier
Declaration
Swift
open class var reuseIdentifier: String { get }