[英]TableView and CollectionView in the same ViewController with Swift
[英]Set TableView and collectionView in ViewController
我正在構建一個 iOS 應用程序,它有多個 collectionView 有些是水平的有些是垂直滾動。
我希望它們一起垂直滾動我閱讀了很多博客並知道可以使用 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 中顯示。
您應該連接 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.