Reputation: 41
Long story short. I have a ViewController that has a ColletionView that's the main component of the page. The CollectionView has 2 reusable cell a Header and a Footer. I would like to have a TableView inside the footer but that's not possible I get the following error when I try to connect the TableView:
"Illegal Configuration: The tableView outlet from the ViewController to the UITableView is invalid. Outlets cannot be connected to repeating content."
My tip is that I want to achieve this in a total wrong way.
I want to achieve the following:
Upvotes: 2
Views: 366
Reputation: 336
I assume you did register the footer/header nib like this:
segmentCollectionView.register(UINib(nibName: /* CellNibName */, bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: /* CellId */)
and then dequeue the cell like this
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == UICollectionView.elementKindSectionFooter {
let cell = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: /* CellId */, for: indexPath) as! /* Your Class */
}
else {
}
}
UITableView
inside the reference /* Your Class */UITableView in the cell class not the
UIViewControllerclass that contains the
UICollectionView`Upvotes: 0
Reputation: 41
[SOLVED]
The solution was the following: I made a CollectionReusableView file for the Footer then exactly when @karem_gohar said I passed the following:
footer.tableView.delegate = footer.self footer.tableView.dataSource = footer.self
I connected the tableView to the CollectionReusableView, I made an array to test it out I filled the tableView with the elements of the array.
Ps.:I made a TableViewCell and linked a label to it. The label showed the element of the array.
Upvotes: 1