[英]Set TableView and collectionView in ViewController
I am building an iOS app which is having multiple collectionView some are horizontal some are vertical scroll.我正在构建一个 iOS 应用程序,它有多个 collectionView 有些是水平的有些是垂直滚动。
I wanted them to scroll vertically together I read a lot of blogs and came to know it can be done using UITableView.我希望它们一起垂直滚动我阅读了很多博客并知道可以使用 UITableView 来完成。 I was implementing UITableView and UICollectionView IN ViewController It this throwing an error.我在 ViewController 中实现了 UITableView 和 UICollectionView 这抛出了一个错误。
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.我是 swift 的新手,有没有人可以帮助我理解这个错误以及如何解决这个问题。
I have made a sample project where I made tableView and collection view different classes it works fine.我制作了一个示例项目,其中我制作了 tableView 和 collection view 不同的类,它工作正常。 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.我需要将它合并到 viewController 中,因为我正在使用 API 从服务器获取一些数据,并且需要在我的 4 个不同的 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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.