【发布时间】:2019-05-29 17:32:34
【问题描述】:
我请求帮助确定正确的方法
当我点击图片时,我需要将文本和她传递给新的 VC,但问题是该项目的结构深度很大
单元格位于collectionView,即tableViewCell中
如何正确实施转移? (单元格数自动生成)
另一个复杂因素是我工作的单元格的代码位于另一个单元格中。
那些。信息的传递也必须写在里面。
import UIKit
import moa
class RealPhotoInfoTableViewCell: UITableViewCell {
@IBOutlet private weak var MyCollection: UICollectionView!
var model: RealPhoto!
func setCollectionViewDataSourceDelegate(dataSourceDelegate: UICollectionViewDataSource & UICollectionViewDelegate, forRow row: Int) {
MyCollection.delegate = self
MyCollection.dataSource = self
MyCollection.reloadData()
}
}
extension RealPhotoInfoTableViewCell: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
print(model?.data.count as Any)
return model?.data.count ?? 0
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "RPhotoCell", for: indexPath) as! RealPhotoCollectionViewCell
cell.realPhotoImage.moa.url = model?.data[indexPath.row].photo
return cell
}
}
【问题讨论】:
标签: swift uitableview uicollectionview