Skip to content

Instantly share code, notes, and snippets.

@Slowhand0309
Last active October 10, 2020 16:58
Show Gist options
  • Save Slowhand0309/192f5316d4e8c081f52b7341076c45d5 to your computer and use it in GitHub Desktop.
Save Slowhand0309/192f5316d4e8c081f52b7341076c45d5 to your computer and use it in GitHub Desktop.
UICollectionView in UITableView
import UIKit
class ItemTableViewCell: UITableViewCell {
@IBOutlet weak var collectionView: UICollectionView! {
didSet {
let nib = UINib(nibName: "ItemCollectionViewCell", bundle: nil)
collectionView.register(nib, forCellWithReuseIdentifier: "ItemCollectionViewCell")
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func set<T: UICollectionViewDelegate & UICollectionViewDataSource>(collectionDataSourceDelegate: T) {
collectionView.delegate = collectionDataSourceDelegate
collectionView.dataSource = collectionDataSourceDelegate
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment