【发布时间】:2017-08-18 11:38:15
【问题描述】:
我有一个UICollectionViewCell,我想在点击时访问谁的数据。数据将在另一个视图控制器中使用...例如,当我点击一个朋友时,下一个呈现的视图控制器将是一个包含点击的朋友数据的页面。
这是我的didSelectItemAt IndexPath
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let layout = UICollectionViewFlowLayout()
let vc = JoinGroupChatController(collectionViewLayout: layout)
vc.selectedIndex = indexPath
let liveCell = LiveCell()
vc.descriptionLabel = liveCell.descriptionLabel.text
present(vc, animated: true, completion: nil)
}
本质上这是我想要做的,但是我需要 indexPaths 特定的描述标签而不是默认的 liveCell 标签文本。
我知道我需要在某个地方使用 indexPath,只是不确定在哪里/如何。 有什么建议吗?
【问题讨论】:
-
你根本不应该得到单元格。您应该从用于填充集合视图的数据模型访问数据。单元格不是您的数据。
标签: ios swift uicollectionviewcell