【发布时间】:2018-05-11 04:57:08
【问题描述】:
所以我有一个带有 CollectionView 和自定义 Cell 的 TableViewController,但我想准备从 CollectionView 到 TableView 的 segue。
我试过了:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "drawSegue" {
let dst = segue.destination as! DrawerViewController
guard let indexPath = cupCollectionView.indexPathsForSelectedItems else{
return
}
dst.cup = cupboards[indexPath.row] as! Cupboard
}
}
但我收到错误 Value of type '[IndexPath]' has no member 'row'。还有另一种方法吗?因为在另一个项目中,我将它从 tableView 使用到 tableView 并且它工作......
这是我的 CollectionView:
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return cupboards.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cupCell", for: indexPath) as! CupboardCollectionViewCell
let cupboard = cupboards[indexPath.row]
cell.cupLabel.text = cupboard.name
return cell
}
提前谢谢你
【问题讨论】:
标签: ios swift uitableview core-data uicollectionview