在单击第二个单元格之前,不会执行我的didSelectItemAt
函数,但是该函数正在使用从第一个单元格单击获得的数据执行。否则,一切都会按预期进行。帮助吗?
func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
let id = boardArray[indexPath.row]
let boardId = id.title
let storyBoard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let boardViewController = storyBoard.instantiateViewController(withIdentifier: "BoardViewController") as! BoardViewController
boardViewController.name = boardId
self.present(boardViewController, animated: true, completion: nil)
}
因此,在单击第二个单元格后,它将显示带有第一个单元格的boardId的“ BoardViewController”等。
谢谢,珠宝
答案 0 :(得分:1)
您使用didDeselectItemAt
代替
func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { }
使用
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { }