Reputation: 15
I have 2 collection view in table view cells and each collection view has Outlet in own table view cell . how i can call and use this two collection view in cellForItemAt
method in view controller.
if (collectionView == self.amazing_Collection) // doesnt work
this is table view methods in view controller
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let section = indexPath.section
if section == 0 {
let cell0 = tableView.dequeueReusableCell(withIdentifier: "searchCell", for: indexPath) as! searchCell
return cell0
}else if section == 1 {
let cell1 = tableView.dequeueReusableCell(withIdentifier: "slideCell", for: indexPath) as! slideCell
return cell0
and this is collection view method for fill image and labels
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "amazingCollecionCell", for: indexPath) as! amazingCollecionCell ////this is work correctly return cell
return cell
//here iwant to say if this collection view execute under lines
let cell_Just_Here = collectionView.dequeueReusableCell(withReuseIdentifier: "justhereproductscell", for: indexPath) as! JustHereProductsCell
//lable fill
return cell_Just_Here
}
}
Upvotes: 0
Views: 447
Reputation: 1133
When tableview's data source method is called, set the collection view's tag
value as indexPath.row
(cell's index path). By this in the collection view's datasource method you will be able to identify the collection view with the tag value and set the cells accordingly.
Hope this helps.
Upvotes: 0