首页 > 解决方案 > 在 ViewController 中设置 TableView 和 collectionView

问题描述

我正在构建一个具有多个 collectionView 的 iOS 应用程序,有些是水平的,有些是垂直滚动的。

我希望它们一起垂直滚动我阅读了很多博客并知道可以使用 UITableView 来完成。我在 ViewController 中实现 UITableView 和 UICollectionView 这会引发错误。

错误:

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]

我是新来的 swift 有没有人可以帮助我理解这个错误以及如何解决这个问题。

我制作了一个示例项目,在其中制作了 tableView 和 collection view 不同的类,它工作正常。我需要将其合并到 viewController 中,因为我正在使用 API 从服务器获取一些数据,并且需要在我的 4 个不同的 collectionView 中显示。

标签: iosswiftuitableviewuiviewcontrolleruicollectionview

解决方案


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


推荐阅读