简体   繁体   中英

Set TableView and collectionView in ViewController

I am building an iOS app which is having multiple collectionView some are horizontal some are vertical scroll.

I wanted them to scroll vertically together I read a lot of blogs and came to know it can be done using UITableView. I was implementing UITableView and UICollectionView IN ViewController It this throwing an error.

Error:

Showing Recent Messages
The dealCollectionViewCell outlet from the BusinesViewControllerr to the UICollectionView 
is invalid. Outlets cannot be connected to repeating content. [12]

Showing Recent Messages
The dealTableViewCel outlet from the BusinesViewControllerr to the UITableViewCell is 
invalid. Outlets cannot be connected to repeating content. [12]

I am new to swift does anyone can help me in understanding this error and how to fix this.

I have made a sample project where I made tableView and collection view different classes it works fine. I need to merge that into viewController because I am fetching some data using API from the server and need to display in my 4 different collectionView.

您应该连接 UITableView 和 UICollectionView 的插座而不是它们的单元格

Use a function in tableviewcell class and in cellforrow at call that function like:
UItableviewClass:
func BindData(data: [String]){
self.myData = data
self.myCollectionView.reloadData()
}

in ViewController:
  cellForRowAt:
   cell.BindData(data: anydata)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM