我在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)