小编jar*_*rns的帖子

如何将数据传递给嵌入在TableViewCell中的UICollectionView(xCode - iOS - Swift 3)

我在TableViewCell中实现了CollectionView,但我需要在CollectionView上读取set单元格的动态数据.

我可以从类TableViewCell读取有关扩展的数据,也许可以帮助我将数据从ViewController传递到类TableViewCell.

 class MultipleTableViewCell: UITableViewCell {

        @IBOutlet fileprivate weak var collectionView: UICollectionView!

    }

    extension MultipleTableViewCell : UICollectionViewDataSource {

        func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
            return 3 // array.count
        }

        func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "foodCell", for: indexPath) as! UserCollectionViewCell

     let dict = array.object(at: indexPath.row) as! NSDictionary //Like this

            cell.name.text = "How do you read data from ViewController"
            cell.email.text = "How do you read data from ViewController"
            cell.phone.text …
Run Code Online (Sandbox Code Playgroud)

xcode uitableview ios uicollectionview swift3

1
推荐指数
1
解决办法
1226
查看次数

标签 统计

ios ×1

swift3 ×1

uicollectionview ×1

uitableview ×1

xcode ×1